Log in

View Full Version : DIV position playing up



Woody
09-23-2007, 01:17 PM
Hi,

I am learning CSS (very slowly), but now I'm stuck again!
I have just added a lovely DD menu to my test site, and now I can't get the main content DIV to sit where it was (top middle). Can anyone explain the error of my ways? Is it to do with absolute positioning?

This site:

http://www.lansdownebaptistchurch.org.uk/test/index1.html

The HTML:
/>
<style type="text/css">
<!--
-->
</style>
<!--[if IE 5]>
<style type="text/css">
/* place css box model fixes for IE 5* in this conditional comment */
.thrColAbsHdr #sidebar1 { width: 180px; }
.thrColAbsHdr #sidebar2 { width: 190px; }
</style>
<![endif]-->
<link href="lbcstylesheet.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
-->
</style>
</head>

<body class="thrColAbsHdr">

<div id="container">
<div id="header">
<h1>&nbsp;</h1>
<!-- end #header --></div>
<div id="sidebar1">
<div id="ddblueblockmenu">

<div class="menutitle">Dynamic Drive</div>
<ul>
<li><a href="http://www.dynamicdrive.com">Home</a></li>
<li><a href="http://www.dynamicdrive.com/new.htm">What's New</a></li>
<li><a href="http://www.dynamicdrive.com/revised.htm">What's Revised</a></li>
<li><a href="http://www.dynamicdrive.com/forums/">Help Forums</a></li>
</ul>

<div class="menutitle">CSS Library</div>
<ul>
<li><a href="http://www.dynamicdrive.com/style/csslibrary/category/C1/">Horizontal CSS Menus</a></li>
<li><a href="http://www.dynamicdrive.com/style/csslibrary/category/C2/">Vertical CSS Menus</a></li>
<li><a href="http://www.dynamicdrive.com/style/csslibrary/category/C4/">Image Effects</a></li>
<li><a href="http://www.dynamicdrive.com/style/csslibrary/category/C6/">Form Effects</a></li>
<li><a href="http://www.dynamicdrive.com/style/csslibrary/category/C5/">Boxes & containers</a></li>
<li><a href="http://www.dynamicdrive.com/style/csslibrary/category/C7/" style="border-bottom-color: black">Links & Buttons</a></li>
</ul>

</div>
<!-- InstanceBeginEditable name="side bar 2" -->
<div id="sidebar2">
<p><img src="images/deadend_03.jpg" alt="have you reached a dead end?" width="162" height="122" /></p>
<p><img src="images/download_06.jpg" alt="download a sermon today" width="164" height="108" /></p>
<p><img src="images/churchlike_09.jpg" alt="what is our church like?" width="164" height="109" class="imgleft" /></p>
<p>&nbsp;</p>
<!-- end #sidebar2 -->
</div>
<!-- InstanceEndEditable --><!-- InstanceBeginEditable name="main content" -->
<div id="mainContent">
<h3> Welcome</h3>
<p align="left">We are a group of ordinary people of different ages and from many different backgrounds who have discovered real life in following Jesus Christ.</p>
<p align="left">We are forgiven through his death for us and believe that he is alive today offering hope to all who will call on him. We trust you will find a warm welcome at our <br />
service and activities.</p>
<p align="left"><span style="font-weight: bold">Our Sunday Services</span> <span style="font-weight: bold">are at:</span></p>
<p align="left" style="font-weight: bold">10.30am and 6.30pm</p>
<p align="left">We also have various events throughout the week covering age groups from toddlers to senior citizens, <br />
and everything inbetween!</p>
<p align="left">If we can help in any way, please do not hesitate to contact us.</p>
<p align="left"><br />
<br />
</p>
</div>



The CSS:


.thrColAbsHdr #container {
position: relative; /* adding position: relative allows you to position the two sidebars relative to this container */
width: 780px; /* using 20px less than a full 800px width allows for browser chrome and avoids a horizontal scroll bar */
background: #FFFFFF;
margin: 0 auto;
text-align: left;
border: 1px solid #000000;
}


#ddblueblockmenu{
border: 1px solid black;
border-bottom-width: 0;
width: 185px;
}

#ddblueblockmenu ul{
margin: 0;
padding: 0;
list-style-type: none;
font: normal 90% 'Trebuchet MS', 'Lucida Grande', Arial, sans-serif;
}

#ddblueblockmenu li a{
display: block;
padding: 3px 0;
padding-left: 9px;
width: 169px; /*185px minus all left/right paddings and margins*/
text-decoration: none;
color: white;
background-color: #2175bc;
border-bottom: 1px solid #90bade;
border-left: 7px solid #1958b7;
}

* html #ddblueblockmenu li a{ /*IE only */
width: 187px; /*IE 5*/
w\idth: 169px; /*185px minus all left/right paddings and margins*/
}

#ddblueblockmenu li a:hover {
background-color: #2586d7;
border-left-color: #1c64d1;
}

#ddblueblockmenu div.menutitle{
color: white;
border-bottom: 1px solid black;
padding-left: 5px;
width: 180px; /*185px minus all left/right paddings and margins*/
background-color: black;
font: bold 90% 'Trebuchet MS', 'Lucida Grande', Arial, sans-serif;
padding-top: 1px;
padding-right: 0;
padding-bottom: 1px;
}

</style>

.thrColAbsHdr #sidebar1 {
position: absolute;
top: 0px;
left: 0;
width: 120px; /* padding keeps the content of the div away from the edges */
font-family: Verdana, Arial, Helvetica, sans-serif;
background-color: #FFFFFF;
margin-top: 191px;
padding-top: 0px;
padding-right: 10px;
padding-bottom: 15px;
padding-left: 20px;
font-size: small;
color: #1F216E;
border-right-width: 0px;
border-right-style: none;
}
.thrColAbsHdr #sidebar2 {
position: absolute;
top: 0px;
right: 0;
width: 160px;
padding-top: 15px;
padding-right: 10px;
padding-bottom: 0px;
padding-left: 10px;
margin-top: 191px;
margin-right: 10px;
margin-bottom: 0px;
margin-left: 595px;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: small;
color: #1F1C6D;
}
.thrColAbsHdr #mainContent {
border-left-width: thin;
border-left-style: solid;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: small;
color: #1F1C6D;
margin-top: 40px;
margin-right: 210px;
margin-bottom: 0;
margin-left: 200px;
padding-top: 0;
padding-right: 10px;
padding-bottom: 0;
padding-left: 30px;
border-left-color: #DE720D;
clear: none;

}
.thrColAbsHdr #footer {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10px;
background-color: #A5BFE2;
clear: none;
padding-top: 0;
padding-right: 10px;
padding-bottom: 0;
padding-left: 10px;
z-index: 0;
}
.thrColAbsHdr #footer p {
margin: 0; /* zeroing the margins of the first element in the footer will avoid the possibility of margin collapse - a space between divs */
padding: 10px 0; /* padding on this element will create space, just as the the margin would have, without the margin collapse issue */
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10px;
color: #1F216E;
background-position: 0px;
text-align: center;
}
.fltrt { /* this class can be used to float an element right in your page. The floated element must precede the element it should be next to on the page. */
float: right;
margin-left: 8px;
}
.fltlft { /* this class can be used to float an element left in your page */
float: left;
margin-right: 8px;
}
a {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: small;
}
a:link {
text-decoration: none;
color: #191373;
}
a:visited {
text-decoration: none;
}
a:hover {
text-decoration: underline;
color: #E1740F;
}
a:active {
text-decoration: none;
}

insanemonkey
09-23-2007, 01:24 PM
why do you have a

</style> in the middle of the css?

and where welcome is

<div id="mainContent">
<h3> Welcome</h3>
<p align="left">We are a group of ordinary people of different ages and from many different backgrounds who have discovered real life in following Jesus Christ.</p>
<p align="left">We are forgiven through his death for us and believe that he is alive today offering hope to all who will call on him. We trust you will find a warm welcome at our <br />
service and activities.</p>
<p align="left"><span style="font-weight: bold">Our Sunday Services</span> <span style="font-weight: bold">are at:</span></p>
<p align="left" style="font-weight: bold">10.30am and 6.30pm</p>
<p align="left">We also have various events throughout the week covering age groups from toddlers to senior citizens, <br />
and everything inbetween!</p>
<p align="left">If we can help in any way, please do not hesitate to contact us.</p>
<p align="left"><br />
<br />
</p>
</div>

where you have div=maincontent for your id, you don't have a id in your css file for your div id.

try putting this into your css file


mainContent {
position: relative;
width: 100%; //percentages are very useful I think
margin: auto;
}

Woody
09-23-2007, 01:51 PM
Hi, thanks for that, but I tried that to no avail.

Maybe I should go back a stage:

I have made a 3 col absolutely positioned header and footer page in DW, and then I want a DD menu in the 1st col (side bar 1) DIV- do I cut and paste the DD menu html which is a DIV too) so that it sits inside the 1st col DIV, or do I replace the 1st col DIV with the menu DIV? Can you nest DIVS? As you can see I have a lot to learn - and advice welcome!:eek:

insanemonkey
09-23-2007, 04:10 PM
oh i c, hmmm, crud monkey....

What you are going to have to do is most likely rebuild you structure I am not that good with divs but you should post this in html and maybe someone will help you....

srry