Forum Moderators: not2easy

Message Too Old, No Replies

container div not wrapping around floated elements

         

kumarsena

6:17 pm on Sep 9, 2004 (gmt 0)

10+ Year Member



i have a design where i have a continer with a number of child elements. because the container didnt wrap around the flaoted elements i used the following hack:

#maindiv:after {content: ""; display: block; height: 0; clear: both; }

and it worked.

but now the child div inside of the container is not wrapping around the content text. i ve tried the above hack but it is not working. the text is inside a div which is again inside another parent div (to sort out ie widht issues). does anyone know how to sort this out?

also im getting a 1px border or space right to to some of the elements regadless of whther they are in natural flow or flaoted right or left.

any help is apreciated
kumar

kumarsena

6:19 pm on Sep 9, 2004 (gmt 0)

10+ Year Member



oh and let me add that this problem of wrapping is only in ff, ie is doinbg good. but the border/space issue is ie exclusive.....

createErrorMsg

12:55 am on Sep 10, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You need to float the parent container. The specs for floats enable them to float OUT of a container (it's actually their main purpose). In order to prevent this, and force the container to stretch and wrap around them, the container itself must be floated.

The reason FF does this and IE doesn't is simple...it's another example of IE's failure to adhere to w3c recommendations. In IE, containers automatically enclose floated elements.

kumarsena

2:36 pm on Sep 10, 2004 (gmt 0)

10+ Year Member



got it,

i had actually used a hack to solve it, but this is better.

one more thing tough...i have a problem with unwanted space/border in ie. have a right flaoted div but its not completly touching the border to the right, if u get me. so is the case for a div that is naturally in the flow (3rd in row, everythign after is floated.)

think ive seen this described somewhere, but off course cant remember when u need it...

kumarsena

3:52 pm on Sep 10, 2004 (gmt 0)

10+ Year Member



would u know......its always the little things isnt it?

i had borders on the first div in the flow. all black. but the container also had a border 10px black so beacuse of this hte width of the fisrt div expanded making what looked like uinwated padding on some the follwoing elemetns. just wondring why firefox didnt show this. technically i woudl say because ie6 was in standard mode, this 'error' would also be seen in ff....