css

 1 <!DOCTYPE html>
 2 <html lang="en">
 3 
 4 <head>
 5     <meta charset="UTF-8">
 6     <meta name="viewport" content="width=device-width, initial-scale=1.0">
 7     <meta http-equiv="X-UA-Compatible" content="ie=edge">
 8     <title>Document</title>
 9     <style>
10         body {
11             text-align: center;
12             color: #fff;
13             line-height: 80px;
14         }
15 
16         h1 {
17             /* inline不能设置宽高,没有 */
18             /* display: inline;
19             height: 20px;
20             padding: 10%; */
21 
22             /* display-inline 我们称之为行内块,可以设置宽高,拥有一切属性 */
23             /* display: inline-block;
24             height: 30px; */
25 
26             /*  display: block 块级元素,占满一行 */
27             display: block;
28             width: 80px;
29             height: 80px;
30             background-color: #000;
31         }
32 
33         h2 {
34             display: inline-block;
35             width: 80px;
36             height: 80px;
37             background-color: #000;
38             /* text-align: center; */
39         }
40 
41         h3 {
42             display: inline;
43             width: 80px;
44             height: 80px;
45 
46             background-color: #000;
47         }
48     </style>
49 </head>
50 
51 <body>
52     <h1>块级元素</h1>
53     <h2>行间块</h2>
54     <br>
55     <h3>行内(没有宽高,我能怎么办)</h3>
56 </body>
57 
58 </html>
原文地址:https://www.cnblogs.com/cisum/p/9596818.html