定义
display 属性规定元素应该生成框的类型
属性值
值 | 描述 |
---|---|
none | 此元素不会被显示。 |
block | 此元素将显示为块级元素,此元素前后会带有换行符。 |
inline | 默认。此元素会被显示为内联元素,元素前后没有换行符。 |
inline-block | 行内块元素。(CSS2.1 新增的值) |
list-item | 此元素会作为列表显示。 |
inherit | 规定应该从父元素继承 display 属性的值。 |
示例
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
.box {
display: inline-block;
}
</style>
</head>
<body>
<div>
<div class="box" style="width: 200px;height: 400px;background-color: aquamarine;"></div>
<div class="box" style="width: 200px;height: 400px;background-color: rgb(197, 169, 183);"></div>
</div>
</body>
</html>