I am using CSS boxes to create three images equally spaced, with three sub titles, also equally spaced. I can’t seem to get the sub titles to cooperate.
See http://clickbasics.com/test_boxes.html
Neither width nor min-with seem to take hold. Thought? Ideas?
Hi,
That’s because elements with display:inline; (other than replaced elements , images etc.) can’t take a width.
If you want to use text-align to center them while using widths then use display: inline-block
One other thing, your auto margins on #boxsub are not doing anything unless you give it a width.
According to Adobe Browser lab, it appears to be working in all browsers except IE7, Firefox 2 -OSX, and FireFox 2 Windows. http://clickbasics.com/test_boxes.html What is the workaround?
Have you considered eliminating that top div that the images are in and just setting them up as image captions.
That will keep the images centered above your text and reduce the code as well. Normally I do those with a <UL> but you can get the same results using divs.
It’s been a while since I messed around with all the FF2 inline-box quirks but this looks like one of those cases when -moz-box-orient: vertical; is needed along with it.
Additionally it looks like FF2 wants the inline-box children to be wrapped in a block. I used a <p> but a <div> should give the same results. When I did not nest the image in a block FF2 did place above the anchor, but it stretched the image.
This seems to be working in K-Meleon for me (it uses the FF2 gecko engine), I don’t have FF2 installed so that’s what I’m testing with.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Test boxes</title>
<style type="text/css">
ul#box {
margin: 0;
padding: 0;
list-style: none;
border: 1px solid #000;
padding: 10px;
text-align: center;
}
#box li {
width: 30%;
min-width: 220px;
[COLOR=Blue]display: -moz-inline-box;[/COLOR]/* for FF2 and K-Meleon */
[COLOR=Blue]-moz-box-orient: vertical;[/COLOR]
display: inline-block;/* for modern browsers */
background: #EEF;
text-align: center;
margin: 5px;
padding: 10px 0;
}
[COLOR=Blue]#box li p[/COLOR] {margin:0;}
#box li img {
width:215px;
height:141px;
margin: 0 auto 20px;
vertical-align:bottom;
}
* html #box li {display: inline;}/* IE6 tripswitch */
*+html #box li {display: inline;}/* IE7 tripswitch */
</style>
</head>
<body>
<ul id="box">
<li>
[COLOR=Blue][B]<p>[/B][/COLOR]<img src="sample.jpg" alt="Family Vacation">[COLOR=Blue][B]</p>[/B][/COLOR]
[COLOR=Blue][B]<p>[/B][/COLOR]<a href="#">Be Family</a>[COLOR=Blue][B]</p>[/B][/COLOR]
</li>
<li>
<p><img src="sample.jpg" alt="Romantic Getaway"></p>
<p><a href="#">Get Romantic</a></p>
</li>
<li>
<p><img src="sample.jpg" alt="Groups"></p>
<p><a href="#">Get Together</a></p>
</li>
</ul>
</body>
</html>