floating divs popping out of container div and looking like shite (1 Viewer)

krystal

New Member
Since 2000
Joined
Aug 14, 2000
Messages
11,476
My problem is that my floating divs don't seem to want to stay within the confines of their container, or rather, their container doesn't stretch down to contain them. This looks like shit because I have a background and borders applied to the container div and it's stopping way up the page. Basically I have 2 divs - one floated left and one margined to the right. The left is for content, the right for a submenu. The container div stretches as far as the length of the right hand div and no further. I've tried applying 'clear:both' classes to the ends of both divs and hey presto, yay it works. Oh no it doesn't. It has the effect of clearing out the divs above which contain breadcrumbing and titles. Anyone managed to solve this issue? Oh and of course, this is an IE bug.

Mucho helpo appreciado.
 
Nope - as in below the other two?

Wavioli said:
did you try adding a third div to the container, and giving that a clear:both attribute?
 
has the same effect. knocks out the top 2 divs above the container div.
ARGH. I may play with a negative top margin. Or something.
I knew there was a reason I never used right hand sub-menus. GAAHH.
 
fixed it. This bad boy did the trick:

.cleared:after {
content: ".";
display: block;
height: 0;
clear: both;
visibility: hidden;
}
/* Hides from IE-mac \*/
* html .clearfix {height: 1%;}
/* End hide from IE-mac */
 
i feel your pain...

goddam internot explorer. There is some bug in explorer, that fucks up floated divs if you have border or padding on them, i was having similar troubles last week. Hang on and ill see if i can dig up the page about it...
 
oh that's fine thanks, I solved the padding thing for myself long ago. I don't like using hacks, because you've no guarantee that the hack will work in future browser versions for one thing. I nest divs to get round the padding problem and apply rules to the inner div.

Wavioli said:
i feel your pain...

goddam internot explorer. There is some bug in explorer, that fucks up floated divs if you have border or padding on them, i was having similar troubles last week. Hang on and ill see if i can dig up the page about it...
 
kirstie said:
oh that's fine thanks, I solved the padding thing for myself long ago. I don't like using hacks, because you've no guarantee that the hack will work in future browser versions for one thing. I nest divs to get round the padding problem and apply rules to the inner div.

actually that site uses very little hacks to get around the problems.

kirstie said:
ok....big deep breath...OKK. I think I have it.

So, care to share?
 
yeah pretty much the 3rd div with clear:both applied to it. Once there was some actual content in the content div and I'd added 50px of padding to the bottom of the body in the CSS that seemed to iron out the 2 divs disappearing up at the top. Thanks for your help!

Wavioli said:
actually that site uses very little hacks to get around the problems.



So, care to share?
 
another possible fix (if i've understood your problem right) is to do a semantic hack (i.e. one in the html) with a non-floated character after the floats.

the logic: your container div doesn't have any content that isn't also enclosed in one or other of the float divs, and so therefore there's nothing 'in' the container to make it 'contain' the floats (it's a bit hard to describe but it makes sense).

the fix is to add in a single character (full stop, comma, whatever) in the container div after all the other divs/content (then use the css to disappear it from view by making it the same colour as the background or something). this forces the container div to display the floats because it has to display a non-floated something-or-other below those floats.

example of this in use in the main nav of the trinity college site. disable styles on the page and you can see a single full stop in the html of the page after the floated <ul> containing the six main nav links. this was done to force the nav background to display properly all the way across even though the nav float doesn't have a 100% width.
 
churs bozz. I tried that alright but it didn't fix what I was doing. I shall keep it in mind for the future however!
 
tom. said:
another possible fix (if i've understood your problem right) is to do a semantic hack (i.e. one in the html) with a non-floated character after the floats.

the logic: your container div doesn't have any content that isn't also enclosed in one or other of the float divs, and so therefore there's nothing 'in' the container to make it 'contain' the floats (it's a bit hard to describe but it makes sense).

the fix is to add in a single character (full stop, comma, whatever) in the container div after all the other divs/content (then use the css to disappear it from view by making it the same colour as the background or something). this forces the container div to display the floats because it has to display a non-floated something-or-other below those floats.

example of this in use in the main nav of the trinity college site. disable styles on the page and you can see a single full stop in the html of the page after the floated <ul> containing the six main nav links. this was done to force the nav background to display properly all the way across even though the nav float doesn't have a 100% width.

well you may not have helped kirstie, but it sorted out a problem I'd been banging my head about! Good man tom!
 

Users who are viewing this thread

Activity
So far there's no one here
Old Thread: Hello . There have been no replies in this thread for 365 days.
Content in this thread may no longer be relevant.
Perhaps it would be better to start a new thread instead.

21 Day Calendar

Darsombra (Kosmische Drone Prog)(US)
Anseo
18 Camden Street Lower, Saint Kevin's, Dublin, Ireland
Gig For Gaza w/ ØXN, Junior Brother, Pretty Happy & Mohammad Syfkhan
Vicar Street
58-59 Thomas St, The Liberties, Dublin 8, Ireland

Support thumped.com

Support thumped.com and upgrade your account

Upgrade your account now to disable all ads...

Upgrade now

Latest threads

Latest Activity

Loading…
Back
Top