March 23, 200818 yr I got hold of a friends blog system which he has now abandoned decided I'd build on the system expand it and so on the css is a mess currently but it was worse before I saw it anyway the left div is displaying below the sidebar and I can't figure out why. heres the link to the live site and a link to a zip of all the files when looking at the main site remember to scroll down so you can see the left div error. Here are the links. Live Site: http://theduckers.net/blog/index.php Zip of The Files: http://theduckers.net/blog.zip Any help would be appreciated thanks in advance
March 23, 200818 yr I think it's because the left div appears after the right div on the html document, and the css does not specify any floats. Add float:left and float:right to the corresponding parts of your CSS and it may fix the problem. If not, you may need to look at the index.php and change it so that the left is generated before the right.
March 24, 200818 yr i use css viewer...and see that your div#right has margin-left:640px....thats why...your div#left appear below the sidebar... hmmm..try this.... <style> div#right{ margin:0px; float:right; } </style>
March 24, 200818 yr Morning Sam, You have two major issues here: You haven't floated the left and right containers, so they will never sit next to each other. Using EM based widths/margins/paddings on elements that need to be next to each other (floated) is asking for a world of hate. Here is the code to fix the issues, and get the site looking great; I will explain after the jump: I've marked all the changes with /* CSS comments */ #container { overflow: hidden; /* Added overflow property to tackle container issues with floats */ width:100%; } #left { background-color: #b9c0c5; width: 498px; /* Changed to a fixed (px) width */ margin-left: 50px; /* Changed to a fixed (px) width */ border-color: #595959; border-width: 1px; border-style: dashed; float: left; /* Added a float */ } #right { padding: 15px; margin-left: 50px; /* Changed to a fixed (px) width */ border-color: #595959; border-width: 1px; border-style: dashed; background-color: #b9c0c5; width: 240px; /* Changed to a fixed (px) width */ float: left; /* Added a float */ } What I've done first is to fix the widths and margins (and paddings if needed) of the left and right columns to a pixel size. I did this because allowing the columns to expand with the text (EM) size, would make the columns jump underneath each other when the text got too big. There are some solutions around this, using max-width for example, but I will leave that up to you. Now we are certain that the columns aren't going to shrink/expand on us, we can tackle the problem of them not sitting next to each other. To do this, we need to stop the <div>s from taking up all the space either side of themselves, so we use the float property. What this does is to remove the <div> from the flow of the document, which basically means it lets everything else flow around it; you can read more about the float property as the Sitepoint CSS reference on floats and clearing. Once we have added float: left; to both #left and #right, we need to tackle an issue with the #container <div>. When you float elements you sometimes get an issue with the container of those elements, where it fails to register the height / existence of the floated elements inside. To tackle this we need to set a width on the container, which you already had (100%), and then you need to set the overflow property to anything other than visible, I usually set it to overflow: hidden;. You should now have a fully functioning multi-column layout! Pat yourself on the back, and take a big sip from your Monday morning cuppa Rob
March 24, 200818 yr Author hey rob I'm not quite sure if you mentioned there. Well anyway the sidebar is on the left and the content on the right I wanted that to be the other way round how would I go about fixing that.
March 24, 200818 yr To move the sidebar, you just need to make sure the <div> with the id "left" is before the one with id "right" in the HTML source code. At the moment right is coming before the left one.
March 24, 200818 yr Author oh. DUH I was pretty silly not to think of that thanks all your help guys again. And getting the nav inline with the left(content) div should I use floats to do that?
March 24, 200818 yr No, no. Only use floats when you need to float things around the element you have the float applied for, hence it being extremely useful for multi-column layouts. The spacing from the left of the window to the content is caused by a margin, so if you set a 50px left margin to the #nav element, you'll be golden.
March 24, 200818 yr Author thanks again everyone I'm reading a book on css at the moment with the help of that and the knowledge of this forum I'm sure I'll get there soon enough with my css coding
March 24, 200818 yr You'll get to a stage where it all starts to come together and really make sense, keep at it!
Create an account or sign in to comment