html - Grow floated elements to fit inside -
i use full width of ul-element floated li-elements. somehow possible using %-values padding of li-elements? can't use fixed width lis, since content not same lenght.
this html code:
<ul>     <li>january</li>     <li>february</li>     <li>march</li>     <li>april</li>     <li>may</li>     <li>june</li>     <li>...</li> </ul>   and here comes css:
ul {     overflow: auto;     list-style: none;     margin: 0;     padding: 0;     width: 600px;     background-color: blue; }  li {     float: left;     padding-left: 3%;     padding-right: 3%;     background-color: #dd0000;     border-left: 1px solid #ffffff; }  li:hover {     background-color: #ff0000; }   find example @ jsfiddle: http://jsfiddle.net/6uy4y/ red li-elements should end, blue ul ends, when changing width of ul.
thanks pointing me right direction!
it looks start of tabular data. i'd use <table>. if i'm mistaking, can fake table css.
ul {   display: table;   list-style: none;   margin: 0;   padding: 0;   width: 100%; }  li {   display: table-cell;   padding: 0 3%; }   here's quick little demo: http://jsbin.com/iwacum/1/edit
Comments
Post a Comment