I have a problem to auto fix UL`s width that LI can float straightly.
If I change css, set UL with a width like '1000px'
, not 'auto'
; that what I want can be done.
However, is there other any settings only by CSS also can achieve same result?, because I want to auto change UL`s width as increasing number of LI.
Now is like
div ul-------------------------------div ul
| /////// //////// |
| /////// li /////// li |
---------------------------------
/////// ////////
////// li /////// li
I want to be like this
div div
ul-------------------------------------------------------------ul
| /////// //////// | /////// //////// |
| /////// li /////// li | /////// li /////// li |
-------------------------------------------------------------
HTML
<div class='test'>
<ul>
<li></li>
<li></li>
<li></li>
<li></li>
</ul>
</div>
CSS
.test{
width: 500px;
height: 100px;
overflow: hidden;
}
.test > ul{
list-style:none;
width: auto;
height: 100%;
background-color:#999;
display: block;
padding: 0px;
margin: 0px;
}
.test > ul > li{
float: left;
display: block;
height: 100%;
width: 180px;
background-color:#99c;
margin-right:10px;
}
Thank you very much for your advice.
li
instead of pixels, like.test > ul > li { width: 25%; } /*reduce this if there is margin left/right*/
– Beforetime