Click here to Skip to main content
15,892,746 members
Please Sign up or sign in to vote.
4.00/5 (2 votes)
See more:
I've created a style called "Thumb", which creates a 100x120px box with a curved border for the purpose of providing a thumbnail and a small caption (see HTML code at the bottom).

If I use the DIV tag, it draws them as I would expect, but will only put 1 on a line.

Using Display: Inline on the DIV tag seems to stop the image from appearing

If I use Span, it looks okay on IE, but on Firefox 4 (RC1) the border does not conform to the size I have provided. Opera is the same as Firefox in not retaining size

I'm trying to avoid using tables because it is dynamic, and the number of boxes I want to draw will vary.

Does anybody know how I keep my boxes with my format, but inline (wrapping at the edges) and works in all browsers?

I'm not much of a web developer (mainly for frustrations like this), so if anybody can help, I would appreciate it.

Thanks

CSS
.Thumb
{
    border-top: #cccc99 1px solid;
    border-right: #cccc99 1px solid;
    border-left: #cccc99 1px solid;
    border-bottom: #cccc99 1px solid;
    border-radius: 4px;
    width: 100px;
    height: 120px;
    padding-right: 5px;
    padding-left: 5px;
    padding-top: 2px;
    padding-bottom: 2px;
}


XML
<div class="Thumb"><img src="blar.png" width="100px" height="100px"><br>Test</div>
<div class="Thumb"><img src="blar.png" width="100px" height="100px"><br>Test</div>
<div class="Thumb" style="display: inline;><img src="blar.png" width="100px" height="100px"><br>Test</div>
<div class="Thumb" style="display: inline;><img src="blar.png" width="100px" height="100px"><br>Test</div>
<span class="Thumb"><img src="blar.png" width="100px" height="100px"><br>Test</span>
<span class="Thumb"><img src="blar.png" width="100px" height="100px"><br>Test</span>
<span class="Thumb"><img src="blar.png" width="100px" height="100px"> Test</span>
<span class="Thumb"><img src="blar.png" width="100px" height="100px"> Test</span

>
Posted
Updated 13-Mar-11 1:48am
v2

1 solution

Welcome to the world of Browser incompatibilities!
You cannot win in all cases. I would try to keep styles as simple as possible; which makes you content rendering much more stable. Remember, you used looks for a Web site for its content, not for decoration. In my opinion, best designer never keeps in mind the idea of impressing anyone with the design but would try to keep design "invisible", focusing on helping readability and functionality.

Additionally, you can play with the styles display:block; display:inline-block;, etc. (See all display styles: http://www.w3schools.com/css/pr_class_display.asp[^].)

It looks like the Mozilla problem is only with the inline display; but not inline-block, which works for me. Instead of attempting one universal .Thumb style, try to create separate styles such as p.Thumb, div.Thumb or span.Thumb.

—SA
 
Share this answer
 
v2
Comments
Espen Harlinn 13-Mar-11 14:26pm    
Good advice :)
Sergey Alexandrovich Kryukov 13-Mar-11 14:55pm    
Well, I tried before answering...
Thank you, Espen.
--SA
MarqW 14-Mar-11 3:31am    
The only reason it was a universal .Thumb style because I was constantly fiddling with the values, and didn't want to have to make them twice.

This site was for a gallery, so there's not much reading, but I take your point.

display:inline-block; works great in Firefox, Opera, and Chrome. Pity about IE though. Maybe when processing the request on the server, my PHP code can feed back an IE version or a standard version

Thanks
Sergey Alexandrovich Kryukov 14-Mar-11 3:39am    
Maybe. IE is a trouble-maker. You can try some more combinations and, after all, simplification is the best approach.
Good luck and thanks for accepting my Answer.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900