CSS display: inline-block effect
The effect of CSS display:inline-block can make many blocks automatically float and arrange horizontally, and there is no need to set additional clear and the following elements will not float to cover the block. This is a bit abstract, in traditional design When DIV blocks are arranged horizontally, web designers usually use the float attribute of CSS to make each DIV block have a floating effect, so that many blocks can be arranged horizontally, but it is easy to cause other than these blocks Blocks also float up, so the web designer will add the clear attribute at the end of the block group to clear the floating effect. The effect of display:inline-block is that we don’t need to set the clear attribute additionally . The block will not be covered. CSS display: inline-block syntax
CSS display: inline-block practical example 1. First use traditional design methods
<!--
#TestDIV1{
float:left;
width:200px;
height:50px;
border:2px #ccc solid;
margin-right:10px;
margin-bottom:10px;
}
# TestDIV2 {
clear:left;
width:100%;
height:10px;
border:2px orange solid;
}
-->
</style>
<div id="TestDIV1"></div>
<div id="TestDIV1">< /div>
<div id="TestDIV1"></div>
<div id="TestDIV2"></div>
CSS display:inline-block practical example 2
<!--
#TestDIV3{
display:inline-block;
width:200px;
height:50px;
border:2px #ccc solid;
margin-right:10px;
margin-bottom:10px;
}
#TestDIV2 {
width:100%;
height:10px;
border:2px orange solid;
}
-->
</style>
<div id="TestDIV3"></div>
<div id="TestDIV3"></div >
<div id="TestDIV3"></div>
<div id="TestDIV2"></div>
The effect of CSS display:inline-block is similar to that of display:inline, but display:inline-block can set the width and height of elements, which is more powerful.
Post a Comment
0 Comments