Forum Moderators: not2easy

Message Too Old, No Replies

Help with thumbnails for gallery

         

rduenas

9:46 pm on Oct 28, 2010 (gmt 0)

10+ Year Member



Hi, I need to arrange some thumbnails for a gallery, but I'm having some problems.

If I put a border on the active image thumbnail, it changes the layout, so I used outline, it keeps the layout but includes the shadow size.

Here some code:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css">
* { padding: 0; margin: 0; border: none; outline: none; }

.container img{
width:50px;
height:50px;
display:inline;
-moz-box-shadow:0px 0px 10px #000;
-webkit-box-shadow:0px 0px 10px #000;
box-shadow:0px 0px 10px #000;
}

.active1{
border: solid 2px #969;
}
.active2{
outline: solid 2px #969;
}

#tn1 {margin:0px;}
#tn2 {margin:-3px 10px -3px -30px ;}
#tn3 {margin:-6px 10px -6px -40px ;}

</style>
</head>

<body>
<div class="container">
<img id='tn1' src="thumbnail.jpg" alt="">
<img id='tn2' class='active1' src="thumbnail.jpg" alt="">
<img id='tn3' src="thumbnail.jpg" alt="">
</div>
<br>
<br>
<div class="container">
<img id='tn1' src="thumbnail.jpg" alt="">
<img id='tn2' class='active2' src="thumbnail.jpg" alt="">
<img id='tn3' src="thumbnail.jpg" alt="">
</div>
</body>
</html>


I am using 50x50 px thumbnails.

Can you give me some advice to keep both border and shadow and keeping the layout?

Thanks.

Ricardo

alt131

1:28 pm on Oct 30, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi Ricardo and welcome to WebmasterWorld ;)

Not sure which browsers and versions you need to support, but it is firefox that incorrectly draws the outline around the shadow. This can be fixed using -moz-outline-offset: -10px; (the length of the shadow), but it is not understood by firefox4+, which need outline-offset: -10px [w3.org] instead.

The trouble is that Opera and winSafari correctly draw the outline "inside" the shadow. Because they also understand outline-offset, a -10px adjustment for firefox means they draw the outline 10px "inside" the edges of the image.

Another option is to use a border with box-sizing: border-box [w3.org]. This will restrict the total width of the image plus left/right borders to 50px rather than 54px, which means the image will be 4px narrower, but the layout won't be affected.

rduenas

11:44 pm on Nov 4, 2010 (gmt 0)

10+ Year Member



Hi, that's what I was looking for. I did it with box-sizing as you said.

Many thanks.

Ricardo