Floating images in a layer, inside another layer
I have the following HTML to center images and links inside a layer:
edit: better example
<style> body {
background-color:#000;
color: #FFF;
} a { font-family: "Broadway",
Broadway,monospace; font-size:
14px; color:
#FFF; }
#images a {
width: 24.99%; display: block;
float: left; text-align: center; }
#container; { top: 30%; left: 15%; }
#main { position: absolute; width: 800px; height: 600px; }
#logo { float:left; background-image:url("1.jpeg");
width: 104; height: 100; }
</style> <div id="main"> <div
id="logo"> </div> <div
id="container"> <div id="images">
<a href="1.html" >
<img src="1.gif" alt="x" width="181" height="173" border="0"
/><br />
One </a> <a href="2.html" >
<img src="2.gif" alt="x" width="181" height="173" border="0"
/><br />
Two </a> <a href="3.html" >
<img src="3.gif" alt="x" width="181" height="173" border="0"
/><br />
Three </a> <a href="4.html" >
<img src="4.gif" alt="x" width="181" height="173" border="0"
/><br />
Four </a> </div></div></div>
+1
source to share
1 answer
-
The main div is 800px wide, so the floating logo div (104px) + 4 images (25% each) is too big for one line, so the final image wraps around the line below. The unfloating logo div will launch the images on a new line in the far left corner.
-
The default position is static - so left and top have no effect.
-
Set
position:relative;
to the container div - be careful with IE6 though, as position: relative is a bit ridiculous if I remember correctly.
0
source to share