I'm having a problem sorting this out, basically it will be a list with icons and text below. Icon size remains the same but the text doesn't, as shown in the picture
.
The problem is when a <li> has a lot of text the rest float to the right of it. How can I sort this out.
My code is below:
ul.iconifier {
width: 100%;
list-style: none;
margin: 0 auto; padding: 0;
}
ul.iconifier li {
float: left;
margin: 10px; padding: 0;
text-align: center;
border: 1px solid #ccc;
width:8em;
height:200px;
-moz-border-radius: 3px; /*--CSS3 Rounded Corners--*/
-khtml-border-radius: 3px; /*--CSS3 Rounded Corners--*/
-webkit-border-radius: 3px; /*--CSS3 Rounded Corners--*/
display: block; /*--IE6 Fix--*/
height:101%;
}
ul.iconifier li a.thumb{
width: 128px;
height: 128px;
overflow: hidden;
display: block;
cursor: pointer;
}
ul.iconifier li a.thumb:hover {
}
ul.iconifier li p {
font: normal 0.75em Verdana, Arial, Helvetica, sans-serif;
margin: 0; padding: 10px 5px;
background: #f0f0f0;
border-top: 1px solid #fff; /*--Subtle bevel effect--*/
text-align:center;
width:118px;
}
ul.iconifier li a {text-decoration: none; color: #777; display: block;}
html:
<ul class="iconifier">
<li>
<a href="#" class="thumb" Title=""><img src="img/sprite.png" alt="Contacts" /></a>
<p><a href="#">English Depatment</a></p>
</li>
<li>
<a href="#" class="thumb" title="art"><img src="img/sprite.png" alt="Art" /></a>
<p><a href="#">Art Deptartment</a></p>
</li>
<li>
<a href="#" class="thumb" title="Travel and Tourism"><img src="img/sprite.png" alt="Travel and Tourism" /></a>
<p><a href="#">Mathematics</a></p>
</li>
<li>
<a href="#" class="thumb" Title=""><img src="img/sprite.png" alt="Contacts" /></a>
<p><a href="#">Business Studies</a></p>
</li>
<li>
<a href="#" class="thumb" Title=""><img src="img/sprite.png" alt="Contacts" /></a>
<p><a href="#">English Depatment with a really long title that will hopefully fall</a></p>
</li>
<li>
<a href="#" class="thumb" title="art"><img src="img/sprite.png" alt="Art" /></a>
<p><a href="#">Art Deptartment</a></p>
</li>
<li>
<a href="#" class="thumb" title="Travel and Tourism"><img src="img/sprite.png" alt="Travel and Tourism" /></a>
<p><a href="#">Mathematics</a></p>
</li>
<li>
<a href="#" class="thumb" Title=""><img src="img/sprite.png" alt="Contacts" /></a>
<p><a href="#">Business Studies</a></p>
</li>
<li>
<a href="#" class="thumb" Title=""><img src="img/sprite.png" alt="Contacts" /></a>
<p><a href="#">English Depatment</a></p>
</li>
<li>
<a href="#" class="thumb" title="art"><img src="img/sprite.png" alt="Art" /></a>
<p><a href="#">Art Deptartment</a></p>
</li>
</ul>
You need to use display: inline-block; instead of float to get them to push the row below them down for modern browsers. For IE6 & IE7 use display: inline.
Replace your ul.iconifier li with this code:
ul.iconifier li
{
margin: 10px;
padding: 0;
text-align: center;
border: 1px solid #ccc;
width: 8em;
-moz-border-radius: 3px; /*--CSS3 Rounded Corners--*/
-khtml-border-radius: 3px; /*--CSS3 Rounded Corners--*/
-webkit-border-radius: 3px; /*--CSS3 Rounded Corners--*/
display: -moz-inline-box; /* mozilla only */
display: inline-block; /* for browsers that support display:inline-block*/
vertical-align: top;
}
Then add this code to make IE6 & IE7 work:
/* Show only to IE7 */
*:first-child + html ul.iconifier li
{
display: inline;
}
/* Show only to IE6 */
* html ul.iconifier li
{
display: inline;
}
I learn this approach from these sites:
http://gtwebdev.com/workshop/layout/inline-block-gallery.php
http://www.css-lab.com/demos/image-display/inline-block-caption.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With