Css floating problem

Thread Solved

Join Date: Dec 2006
Posts: 28
Reputation: trihaitran is an unknown quantity at this point 
Solved Threads: 0
trihaitran trihaitran is offline Offline
Light Poster

Css floating problem

 
0
  #1
Jun 19th, 2007
Hi, I new to CSS and I can't seem to find the solution to my problem anywhere online. The page in question is here

Right now the page looks like this:

here

This is what I want it to look like:
here

I don't want any text to wrap around the menu, but stay aligned on the right side of the page. I tried to extend the menu vertically, but that pushes the footer really far down, and as every page has a different length, hardcoding the height of the menu is a bad idea. I know that css must have some kind of function to get the behaviour that I want, but I just don't know what it is. Maybe there is something wrong with the way that the floating was done.

My css file is at here

Thanks so much.
Last edited by trihaitran; Jun 19th, 2007 at 6:25 pm.
Reply With Quote Quick reply to this message  
Join Date: Apr 2007
Posts: 437
Reputation: Fungus1487 is on a distinguished road 
Solved Threads: 50
Fungus1487's Avatar
Fungus1487 Fungus1487 is offline Offline
Posting Pro in Training

Re: Css floating problem

 
0
  #2
Jun 20th, 2007
two ways.

1) USE TABLES

2) add a margin to your content i.e.
HTML and CSS Syntax (Toggle Plain Text)
  1. <div style="margin-left:200px;">CONTENT HERE, CONTENT HERE</div>

hope that helps
Last edited by Fungus1487; Jun 20th, 2007 at 7:11 pm. Reason: mistake :D
When Autumn Falls [ http://www.whenautumnfalls.co.uk ] &&
Designdotworks [ http://www.designdotworks.co.uk ] Web / Graphic / Software Design
Reply With Quote Quick reply to this message  
Join Date: Jan 2007
Posts: 3,203
Reputation: MidiMagic has a spectacular aura about MidiMagic has a spectacular aura about 
Solved Threads: 164
MidiMagic's Avatar
MidiMagic MidiMagic is offline Offline
Nearly a Senior Poster

Re: Css floating problem

 
0
  #3
Jun 20th, 2007
Give each one its own div with a width style.
Daylight-saving time uses more gasoline
Reply With Quote Quick reply to this message  
Join Date: Jun 2007
Posts: 3
Reputation: Pete_UK is an unknown quantity at this point 
Solved Threads: 1
Pete_UK Pete_UK is offline Offline
Newbie Poster

Re: Css floating problem

 
0
  #4
Jun 21st, 2007
Hi there,

A simple way to do this, since you have only 2 columns is to use the float command.

For your menu element you can write:

#menu {
float: left;
width: 100px;
margin: 0px 10px 0px 0px;
}

you don't need to declare a height, it will auto extend depending on your content, useful if you want to add more in stuff in below it.

for the content/ 2nd column you can write:

#content {
float: right;
width: 400px;
}

This should mean that your menu will appear on the far left of your screen and the content appears on the far right of your screen.

To make this display properly you make a container layer which has the 2 elements inside it. this means that the menu item will go to the far left of the inside of the container and the content column will go to the far right inside of the container.

#container {
width: 510px;
}

Hope that helps you out, I've posted this as an example below:

HTML and CSS Syntax (Toggle Plain Text)
  1. <html>
  2. <style type="text/css">
  3. <!--
  4.  
  5. #container {
  6. width: 512px;
  7. border: 1px Solid #000;
  8. }
  9.  
  10. #menu {
  11. float: left;
  12. width: 100px;
  13. background-color: #CCC;
  14. margin: 0px 10px 0px 0px;
  15. }
  16.  
  17. #content {
  18. float: right;
  19. width: 400px;
  20. background-color: #EEE;
  21. }
  22.  
  23. -->
  24. </style>
  25.  
  26. <body>
  27. <div id="container">
  28. <div id="menu">
  29. some text here
  30. </div>
  31.  
  32. <div id="content">
  33. blah blah blah
  34. </div>
  35. </div>
  36. </body>
  37. </html>

if in doubt a good reference point for CSS (and most web things) is at: http://www.w3schools.com/css/default.asp

give us a shout if you don't understand.

Cheers,

pete.
Reply With Quote Quick reply to this message  
Join Date: Jun 2007
Posts: 10
Reputation: DrTsus is an unknown quantity at this point 
Solved Threads: 1
DrTsus DrTsus is offline Offline
Newbie Poster

Re: Css floating problem

 
0
  #5
Jun 21st, 2007
Float one left, float one right in a container with a footer with the clear: both; attribute.
Reply With Quote Quick reply to this message  
Join Date: Dec 2006
Posts: 28
Reputation: trihaitran is an unknown quantity at this point 
Solved Threads: 0
trihaitran trihaitran is offline Offline
Light Poster

Re: Css floating problem

 
0
  #6
Jun 22nd, 2007
Thanks so much for the help. It was a pretty simple solution after all.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the HTML and CSS Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC