css - inline\inline-block\block

时间:2021-12-05 02:13:53
 <!DOCTYPE html>
<html lang="en"> <head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<style>
body {
text-align: center;
color: #fff;
line-height: 80px;
} h1 {
/* inline不能设置宽高,没有 */
/* display: inline;
height: 20px;
padding: 10%; */ /* display-inline 我们称之为行内块,可以设置宽高,拥有一切属性 */
/* display: inline-block;
height: 30px; */ /* display: block 块级元素,占满一行 */
display: block;
width: 80px;
height: 80px;
background-color: #000;
} h2 {
display: inline-block;
width: 80px;
height: 80px;
background-color: #000;
/* text-align: center; */
} h3 {
display: inline;
width: 80px;
height: 80px; background-color: #000;
}
</style>
</head> <body>
<h1>块级元素</h1>
<h2>行间块</h2>
<br>
<h3>行内(没有宽高,我能怎么办)</h3>
</body> </html>