...

View Full Version : DIV and list help



bart
06-16-2012, 11:03 AM
Hi

I am redesigning a family holiday website of mine http://www.cornwallholidayhome.com/2012site/ but it has been a couple of years since I did any proper CSS coding so I am a bit rusty.

The site has 3 columns and there are 2 navigation bars (which I used from a template site) which are inside a wrapper. The top is called navtop and the bottom one is called navbottom. After I added placeholder text to the centre column I added the bottom navigation bar however it postioned itself at the bottom of the wrapper but the background colour merged upwards.

Also if I write in the centre column and it reached the bottom the DIV's merge together (the background colour of the bottom nav bar pushed upwards). As long as the text does not reach the bottom of the centre DIV then it is ok. I tried playing about with the code but the only way I could get the bottom nav bar to load correctly was to set the top margin at 705px which is what is set currently however as you can see the issue with the DIV's merging still occurs. It looks as though it is inheriting another attribute but I cannot work out what. The bottom nav bar should look like this - http://i.imgur.com/SpLj9.jpg

Is there a better way to set the bottom nav bar in the correct place and if so will it prevent the problem with the DIV's merging? (i.e if I type beyond the bottom of the centre column it will push the bottom nav bar and the bottom wrapper downwards

The website is http://www.cornwallholidayhome.com/2012site/index.html and the CSS is at http://www.cornwallholidayhome.com/2012site/elements/css/main.css

Thanks for any assistance
-Jim

aliqui
06-16-2012, 11:29 PM
Honestly your code is a mess. You've got tags opening and closing in wrong places. Your CSS has some weird stuff going on too. I'm amazed the page looks as good as it does.

I'd suggest you start by validating and correcting the pages.

HTML: Found 11 errors
http://validator.w3.org/#validate_by_upload

CSS: Found 2 errors
http://jigsaw.w3.org/css-validator/#validate_by_upload

Ultimately I believe your issue is with relative and absolute positioning. It appears your navigation area is intended to be absolute, but you don't have a positioning tag in your CSS for navbottom. If you add a 100% height to your contentwrapper you'll see the navigation blow up due to a margin-top of 751px.

Excavator
06-17-2012, 03:42 PM
Hello bart,
Look how easy you can make it without using negative margins, floating full width elements.

Your document will expand to contain what you put in it if you do not specify a height, assuming you've cleared your floats (http://www.quirksmode.org/css/clearing.html).

This might help you get started with your re-write. You'll still need to adjust some widths and add your borders... to do that, you will need to be familiar with the box model.
See the box model here (http://www.w3.org/TR/CSS2/box.html). The box model says that whatever you put inside an element cannot be larger than that element. margin/padding/border all count when figuring width/height.


<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
<style type="text/css">
html, body {
margin: 0;
background: #fc6;
font: 100% Arial, Helvetica, sans-serif;
}
#container {
width: 950px;
margin: 30px auto;
background: #fff;
overflow: auto;
box-shadow: 0 0 20px #8493A6;
}
nav {
height: 40px;
width: 940px;
margin: 0 auto;
background: #333;
}
#headerimage {
margin: 15px auto;
padding: 15px;
display: block;
box-shadow:0px 0px 4px #333333
}
#left, #right, #center {padding: 25px;}
#left {
width: 250px;
float: left;
}
#right {
width: 100px;
float: right;
}
#center {
margin: 0 150px 0 300px;
}
</style>
</head>
<body>
<div id="container">
<img src="http://www.cornwallholidayhome.com/2012site/elements/css/bannertop.jpg" alt="holiday home" width="800" height="325" id="headerimage">
<nav></nav>
<div id="left">left column</div>
<div id="right">right column</div>
<div id="center">
<p>
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna
<br /><br />
aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no
<br /><br />
sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam
<br /><br />
nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo
<br /><br />
duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
</p>
<p>
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna
<br /><br />
aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no
<br /><br />
sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam
<br /><br />
nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo
<br /><br />
duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
</p>
<!--end center--></div>
<nav></nav>
<!--end container--></div>
</body>
</html>

<code>me</code>
06-17-2012, 10:25 PM
Hi Bart,

Some really great advise from Excavator here! Once you get this sorted, you may want to bookmark a resource like CSSReset (http://cssreset.com). Really good free tutorials and help available there for users of all levels, even folks who rarely need to touch any code.

bart
06-18-2012, 11:35 PM
Thank you for all the help especially Excavator as your code was perfect! I have used your template and it works great floating the columns.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum