CSS uses float to make ul li horizontal
Not long ago, I introduced a " CSS ul li horizontal level " design method. The technique used is CSS display inline level presentation syntax, which is a relatively easy standard method. This article will introduce another CSS production ul li horizontal level technique. , Use the built-in CSS feature of float ( float ) to make each li item float horizontally. Although horizontal and horizontal effects can be achieved, there is a little difference between the use of float and display inline . See the example for a clearer view .
CSS uses float to make ul li horizontal horizontal example 1. The difference between float and display inline
<!--
#A ul li {
float:left;
}
#B ul li {
display:inline;
}
-->
</style>
<div id="A">
< ul>
<li>This is project one</li>
<li>This is project two</li>
</ul>
</div>
<div id="B">
<ul>
<li>This is project one </li>
<li>This is project two</li>
</ul>
</div>
Here is item oneHere is item two
CSS uses float to make ul li horizontal and horizontal example 2. Add width to each li
<!--
ul li {
border:1px #cccccc solid;
width: 200px;
float:left;
}
-->
</style>
<ul>
<li>Here is item one </li>
<li>This is project two</li>
</ul>
- Here is project one
- Here is project two
In order to be able to clearly show the visual effect of the width, we have added the effect of a border ( CSS border ) in the example , that is, the border part in the syntax , width:200px is to set the width of each li item to 200px, if you need Adding the effect of width to each item, using float is easier than displaying inline .
Post a Comment
0 Comments