Going crazy with Float

This is a discussion on "Going crazy with Float" within the Web Page Design section. This forum, and the thread "Going crazy with Float are both part of the Design Your Website category.



Go Back   Webforumz.com > Main Forums > Design Your Website > Web Page Design

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Nov 28th, 2006, 11:57
Junior Member
Join Date: Nov 2006
Location: London
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Going crazy with Float

Hello Everybody,
I just joined this Forum and hope that you can help me. I am going crazy by trying to position to div tags (content & right column) next to each other and can't find the problem as this happens the first time

I am having one div as a container into which I inserted a banner div, navi div, content div and one right column div. I do it this way as this helps to get the layour right for IE and FF. Anyway as soon as I try to float the content and the right column they jump out of the container and screw up the layout.

Did someone of you had the same problem and was able to fix it?

Your help would be really appreciated!

Best wishes
Sporky
Reply With Quote

  #2 (permalink)  
Old Nov 28th, 2006, 12:23
Ryan Fait's Avatar
SuperMember

SuperMember
Join Date: May 2006
Location: Las Vegas
Posts: 3,786
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Going crazy with Float

Floats are a tricky thing to get the hang of. However, a link would be best.
Reply With Quote
  #3 (permalink)  
Old Nov 28th, 2006, 13:09
Junior Member
Join Date: Nov 2006
Location: London
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Going crazy with Float

Hi,
Thank you for your response. Since the site is not launched yet, please see code and script below:

</head>
<body>
<div id="divContainer">
<div id="divBanner"></div>
<div id="divNavi">Content for id "divNavi" Goes Here</div>
<div id="divMain">Content for id "divMain" Goes Here</div>
<div id="divRightNavi">Content for id "divRightNavi" Goes Here</div>
</div>
<div id="divfooter">Content for id "divfooter" Goes Here</div>
</body>
</html>

SCRIPT:
divContainer {
width: 70%;
border: thin solid #CCCCCC;
background-color: #FFFFFF;
margin-left: 15%;
}
#divBanner {
width: 100%;
background-image: url(../images/banneridee2.gif);
background-repeat: repeat-y;
height: 150px;
}
#divNavi {
padding: 3px 0px 3px 5%;
background-color: #CCCCCC;
width: 95%;
}
#divMain {
float:left;
width: 60%;
padding-left: 5%;
background-image: url(../images/logo_water_background.gif);
padding-top: 3%;
background-repeat: no-repeat;
height: 400px;
text-align: justify;
}
#divRightNavi {
float:right;
width:30%;
height: 400px;
border-left-width: thin;
border-left-style: dotted;
border-left-color: #CCCCCC;
}

Hope this is clear and you can see where I am going wrong.
Thank you so much for your help.
Regards
Sporky
Reply With Quote
  #4 (permalink)  
Old Nov 28th, 2006, 13:49
Most Reputable Member
Join Date: Apr 2006
Location: Cornwall, UK
Posts: 1,310
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Going crazy with Float

You might find the Templates tutorial, available via the link in the sticky at the top of the css forum, helpfull.
Reply With Quote
  #5 (permalink)  
Old Nov 28th, 2006, 18:13
Ryan Fait's Avatar
SuperMember

SuperMember
Join Date: May 2006
Location: Las Vegas
Posts: 3,786
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Going crazy with Float

Ah, I think I see the problem. When using floats, you are essentially taking the elements out of the normal flow of the document. To sort of force the browser to recognize that these elements are taking up space, you need more more class and div.

Code: Select all
.clear {
    width: 100%;
    height: 1px;
    margin: 0 0 -1px;
    clear: both;
}
Code: Select all
<body>
    <div id="divContainer">
        <div id="divBanner"></div>
        <div id="divNavi">Content for id "divNavi" Goes Here</div>
        <div id="divMain">Content for id "divMain" Goes Here</div>
        <div id="divRightNavi">Content for id "divRightNavi" Goes Here</div>
        <div class="clear"></div>
    </div>
    <div id="divfooter">Content for id "divfooter" Goes Here</div>
</body>
That should do it for you. I wrote an article about clearing floats. You'll find it at the bottom of the sticky in this forum if you're interested in reading up on it a bit more.
Reply With Quote
  #6 (permalink)  
Old Nov 28th, 2006, 19:34
Daniel's Avatar
Elite Veteran
Join Date: Sep 2006
Location: The Kingdom of Rabbits
Age: 21
Posts: 2,051
Blog Entries: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Going crazy with Float

I love sporks!!
Last Blog Entry: Assassin's Creed (Nov 22nd, 2007)
Reply With Quote
  #7 (permalink)  
Old Nov 29th, 2006, 09:28
Junior Member
Join Date: Nov 2006
Location: London
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Going crazy with Float

Hi,
Thanks a lot for this. I will definitely try this one, but have found another solution in the meantime by just giving a fixed height to the container div and that also worked well.
Best wishes
Sporky
Reply With Quote
  #8 (permalink)  
Old Nov 30th, 2006, 01:52
Ryan Fait's Avatar
SuperMember

SuperMember
Join Date: May 2006
Location: Las Vegas
Posts: 3,786
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Going crazy with Float

The only problem with that is if the content exceeds that, the container won't expand.
Reply With Quote
Reply

Tags
css float

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Help!! probably stupid Q. but I'm going crazy 'cos of it nutbolt Starting Out 1 Feb 6th, 2007 16:44
Problems with float:left float:right nvidiajoe Web Page Design 8 Nov 17th, 2006 20:24
Crazy menus... escaflowne11 Web Page Design 2 Oct 1st, 2006 16:56
What I'm working on (idea is crazy) buyseconds Introduce Yourself 4 Nov 18th, 2005 13:58


All times are GMT. The time now is 23:44.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43