Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Help Me With This Guys

Featured Replies

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

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.

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>

Morning Sam,

 

You have two major issues here:

  1. You haven't floated the left and right containers, so they will never sit next to each other.
  2. 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

  • 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.

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.

  • 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?

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. :)

  • 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

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

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.