newbi
08-07-2006, 02:43 PM
Hi All - Gotten stuck with my layout and I'd like to see if anyone has a brilliant idea. It's probably very simple and I'm just missing it.
Here's the relevant HTML:
<body>
<div id="wrapper">
<div id="header">
<!-- image will come here: <img src="HomePageLogo.jpg" alt="" height="xx" width="yy" /> -->
<h1>{<span> Title </span>}</h1>
<div id="header-bottom">
<p><a href="HomeH.html" target="_self">Link</a></p>
</div> <!-- header-bottom -->
</div> <!-- header -->
<div id="main">
<div id="content">
<h2>Heading</h2>
<p>Text will come here.</p>
</div> <!-- content -->
<div id="sections">
<ul id="hoverbox">
<li><a href="#"><img src="images/photo.jpg" alt="Photo" /><img src="images/photo.jpg" alt="Photo" class="preview" /></a></li>
<li><a href="#"><img src="images/photo.jpg" alt="Photo" /><img src="images/photo.jpg" alt="Photo" class="preview" /></a></li>
<li><a href="#"><img src="images/photo.jpg" alt="Photo" /><img src="images/photo.jpg" alt="Photo" class="preview" /></a></li>
<li><a href="#"><img src="images/photo.jpg" alt="Photo" /><img src="images/photo.jpg" alt="Photo" class="preview" /></a></li>
</ul>
</div> <!-- sections -->
<div id="clearone"> </div>
</div> <!-- main -->
</div> <!-- wrapper -->
</body>
</html>
And the rel. CSS:
body {
margin: 0;
padding: 0;
background-color: f5f5f5;
color: #626477;
font: Georgia, "Palatino Linotype", "Trebuchet MS", sans-serif;
}
#wrapper {
background-color: transparent;
margin: 0 250px 15px 15px;
border: 1px solid black;
padding: 10px;
height: auto;
}
#main {
margin-top: 20px;
border: 1px solid blue;
position: relative;
}
#content {
margin: 0 0 0 200px;
border: 1px solid red;
padding: 0 0 0 1em;
width: 300px;
}
#sections {
/* position: absolute;
top: 0;
left: 0; */
float: left;
width: 160px;
margin: 0;
padding: 0;
border: 1px solid green;
}
#clearone {
clear: both;
height: 1px;
}
Note: the borders are just so I can see what's where and the typed out part in the 'sections' div is just me experimenting with absolute positioning for that div.
Anyway, here's the problem. I'm trying to float the sections div right alongside the content div - essentially a two-column layout w/ header. For some odd reason, the sections div will not float next to the content div, rather, it stays on the left but starts on the same line the content div ends. So it's below and to the left of it.
When I use abs positioning it goes where I want it, the problem then is that the main div becomes shorter than the sections div (due to the latter being removed from the doc flow) and I don't know how to fix that.
Could someone please advise as to what I'm doing wrong and/or which one should I go with - absolute or float?
Thank you so much and if you need the rest of the code just yell.
Thanks!
Here's the relevant HTML:
<body>
<div id="wrapper">
<div id="header">
<!-- image will come here: <img src="HomePageLogo.jpg" alt="" height="xx" width="yy" /> -->
<h1>{<span> Title </span>}</h1>
<div id="header-bottom">
<p><a href="HomeH.html" target="_self">Link</a></p>
</div> <!-- header-bottom -->
</div> <!-- header -->
<div id="main">
<div id="content">
<h2>Heading</h2>
<p>Text will come here.</p>
</div> <!-- content -->
<div id="sections">
<ul id="hoverbox">
<li><a href="#"><img src="images/photo.jpg" alt="Photo" /><img src="images/photo.jpg" alt="Photo" class="preview" /></a></li>
<li><a href="#"><img src="images/photo.jpg" alt="Photo" /><img src="images/photo.jpg" alt="Photo" class="preview" /></a></li>
<li><a href="#"><img src="images/photo.jpg" alt="Photo" /><img src="images/photo.jpg" alt="Photo" class="preview" /></a></li>
<li><a href="#"><img src="images/photo.jpg" alt="Photo" /><img src="images/photo.jpg" alt="Photo" class="preview" /></a></li>
</ul>
</div> <!-- sections -->
<div id="clearone"> </div>
</div> <!-- main -->
</div> <!-- wrapper -->
</body>
</html>
And the rel. CSS:
body {
margin: 0;
padding: 0;
background-color: f5f5f5;
color: #626477;
font: Georgia, "Palatino Linotype", "Trebuchet MS", sans-serif;
}
#wrapper {
background-color: transparent;
margin: 0 250px 15px 15px;
border: 1px solid black;
padding: 10px;
height: auto;
}
#main {
margin-top: 20px;
border: 1px solid blue;
position: relative;
}
#content {
margin: 0 0 0 200px;
border: 1px solid red;
padding: 0 0 0 1em;
width: 300px;
}
#sections {
/* position: absolute;
top: 0;
left: 0; */
float: left;
width: 160px;
margin: 0;
padding: 0;
border: 1px solid green;
}
#clearone {
clear: both;
height: 1px;
}
Note: the borders are just so I can see what's where and the typed out part in the 'sections' div is just me experimenting with absolute positioning for that div.
Anyway, here's the problem. I'm trying to float the sections div right alongside the content div - essentially a two-column layout w/ header. For some odd reason, the sections div will not float next to the content div, rather, it stays on the left but starts on the same line the content div ends. So it's below and to the left of it.
When I use abs positioning it goes where I want it, the problem then is that the main div becomes shorter than the sections div (due to the latter being removed from the doc flow) and I don't know how to fix that.
Could someone please advise as to what I'm doing wrong and/or which one should I go with - absolute or float?
Thank you so much and if you need the rest of the code just yell.
Thanks!