473,568 Members | 3,038 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problems with float in nested divs

Hi,

I have a problem with float in firefox/mozilla, the 'ads'-div doesn't
resize on the height with the 'ads_left' and 'ads_right'. In IE there is
no problem but in FF there is. The 'ads'-div do not resize at all.

How come?

HTML
<div id="ads">
<div id="ads_left">c ontent</div>
<div id="ads_right"> content</div>
</div>

CSS

#ads {width: 510px; height: auto;}

#ads_left { float: left; width: 240px;}

#ads_right { float: right; width: 240px;}

Thanks for any help I could get!

/ Gnolen
Jul 21 '05 #1
7 17325
Gnolen <he***********@ hotmail.com> wrote:
I have a problem with float in firefox/mozilla, the 'ads'-div doesn't
resize on the height with the 'ads_left' and 'ads_right'. In IE there is
no problem but in FF there is. The 'ads'-div do not resize at all.

<div id="ads">
<div id="ads_left">c ontent</div>
<div id="ads_right"> content</div>
</div>

#ads {width: 510px; height: auto;}
#ads_left { float: left; width: 240px;}
#ads_right { float: right; width: 240px;}


Floated elements are taken out of the doument flow and hence do not
contribute to the height of their parent. Hence 'ads' has no content
and thus no height. You need an element after 'ads_right' and before
the end of 'ads' with clear: both; set.

Steve

--
"My theories appal you, my heresies outrage you,
I never answer letters and you don't like my tie." - The Doctor

Steve Pugh <st***@pugh.net > <http://steve.pugh.net/>
Jul 21 '05 #2
Thanks Steve!

Yeah, this was the problem. After searching the net for clear: both; I
found this code from
http://www.positioniseverything.net/easyclearing.html which I used on
'ads'-div:

..clearfix:afte r {
content: ".";
display: block;
height: 0;
clear: both;
visibility: hidden;
}

..clearfix {display: inline-table;}

/* Hides from IE-mac \*/
* html .clearfix {height: 1%;}
..clearfix {display: block;}
/* End hide from IE-mac */

Thanks, it works great now!

/ Gnolen
Steve Pugh wrote:
Gnolen <he***********@ hotmail.com> wrote:

I have a problem with float in firefox/mozilla, the 'ads'-div doesn't
resize on the height with the 'ads_left' and 'ads_right'. In IE there is
no problem but in FF there is. The 'ads'-div do not resize at all.

<div id="ads">
<div id="ads_left">c ontent</div>
<div id="ads_right"> content</div>
</div>

#ads {width: 510px; height: auto;}
#ads_left { float: left; width: 240px;}
#ads_right { float: right; width: 240px;}

Floated elements are taken out of the doument flow and hence do not
contribute to the height of their parent. Hence 'ads' has no content
and thus no height. You need an element after 'ads_right' and before
the end of 'ads' with clear: both; set.

Steve

Jul 21 '05 #3
On Wed, 09 Mar 2005 16:53:52 GMT Gnolen wrote:
Hi,

I have a problem with float in firefox/mozilla, the 'ads'-div doesn't
resize on the height with the 'ads_left' and 'ads_right'. In IE there is
no problem but in FF there is. The 'ads'-div do not resize at all.

How come?

HTML
<div id="ads">
<div id="ads_left">c ontent</div>
<div id="ads_right"> content</div>
</div>

CSS

#ads {width: 510px; height: auto;}

#ads_left { float: left; width: 240px;}

#ads_right { float: right; width: 240px;}

Thanks for any help I could get!

/ Gnolen


You should set the ads division to a known height since that is the parent
and you know it will have content.
As long as it is not in another container, it should expand as needed.
I'd start off with the height of what ever image it is you're going to use
initially.

#ads {width:800px; height:100px;}

Jul 21 '05 #4
Thanks Richard,

But I need it to expand with the changeable content in it. And it will
be in a nested div that have to expend with it to.

But the above fix fixed the problem.

/ Gnolen

Richard wrote:
On Wed, 09 Mar 2005 16:53:52 GMT Gnolen wrote:

Hi,

I have a problem with float in firefox/mozilla, the 'ads'-div doesn't
resize on the height with the 'ads_left' and 'ads_right'. In IE there is
no problem but in FF there is. The 'ads'-div do not resize at all.

How come?

HTML
<div id="ads">
<div id="ads_left">c ontent</div>
<div id="ads_right"> content</div>
</div>

CSS

#ads {width: 510px; height: auto;}

#ads_left { float: left; width: 240px;}

#ads_right { float: right; width: 240px;}

Thanks for any help I could get!

/ Gnolen

You should set the ads division to a known height since that is the parent
and you know it will have content.
As long as it is not in another container, it should expand as needed.
I'd start off with the height of what ever image it is you're going to use
initially.

#ads {width:800px; height:100px;}

Jul 21 '05 #5
"Richard" <An*******@127. 001> wrote:
On Wed, 09 Mar 2005 16:53:52 GMT Gnolen wrote:
I have a problem with float in firefox/mozilla, the 'ads'-div doesn't
resize on the height with the 'ads_left' and 'ads_right'. In IE there is
no problem but in FF there is. The 'ads'-div do not resize at all.

<div id="ads">
<div id="ads_left">c ontent</div>
<div id="ads_right"> content</div>
</div>

#ads {width: 510px; height: auto;}
#ads_left { float: left; width: 240px;}
#ads_right { float: right; width: 240px;}
You should set the ads division to a known height since that is the parent
and you know it will have content.


Technically it doesn't have any content in CSS terms for the reason
given in my post. And unless all the contents of the two floated divs
are images you have no way of knowing how much height will be needed,
As long as it is not in another container, it should expand as needed.
No it won't. See my post for the reason why.
I'd start off with the height of what ever image it is you're going to use
initially.


Are you assuming that just because the divs are labelled as being
'ads' that they will contain nothing but images?

Steve

--
"My theories appal you, my heresies outrage you,
I never answer letters and you don't like my tie." - The Doctor

Steve Pugh <st***@pugh.net > <http://steve.pugh.net/>
Jul 21 '05 #6
ads_left will contain text(news) and ads_right will contain images.

Is it correct what I did do you think? Works alright thought and that is
what matters I think.

Thanks,

Gnolen

Steve Pugh wrote:
"Richard" <An*******@127. 001> wrote:
On Wed, 09 Mar 2005 16:53:52 GMT Gnolen wrote:

I have a problem with float in firefox/mozilla, the 'ads'-div doesn't
resize on the height with the 'ads_left' and 'ads_right'. In IE there is
no problem but in FF there is. The 'ads'-div do not resize at all.

<div id="ads">
<div id="ads_left">c ontent</div>
<div id="ads_right"> content</div>
</div>

#ads {width: 510px; height: auto;}
#ads_left { float: left; width: 240px;}
#ads_right { float: right; width: 240px;}


You should set the ads division to a known height since that is the parent
and you know it will have content.

Technically it doesn't have any content in CSS terms for the reason
given in my post. And unless all the contents of the two floated divs
are images you have no way of knowing how much height will be needed,

As long as it is not in another container, it should expand as needed.

No it won't. See my post for the reason why.

I'd start off with the height of what ever image it is you're going to use
initially.

Are you assuming that just because the divs are labelled as being
'ads' that they will contain nothing but images?

Steve

Jul 21 '05 #7
In article <fh************ *************** *****@4ax.com>, Steve Pugh writes:
Gnolen <he***********@ hotmail.com> wrote:

<div id="ads">
<div id="ads_left">c ontent</div>
<div id="ads_right"> content</div>
</div>

#ads {width: 510px; height: auto;}
#ads_left { float: left; width: 240px;}
#ads_right { float: right; width: 240px;}


Floated elements are taken out of the doument flow and hence do not
contribute to the height of their parent. Hence 'ads' has no content
and thus no height. You need an element after 'ads_right' and before
the end of 'ads' with clear: both; set.


Why is it that way, anyhow? I'm not disputing that it is -- I know it
is from painful experience. But, it seems to me that this violates
the block-structured paradigm. The floats were declared within the
"ads" block -- why does their scope extend outside of it?

Was there some good reason for the behavior to be defined this way, or
was it just an unintended consequence of some other decision?

The nasty side-effect of this is, of course, that in situations like
this one does need to add a content-free element to end the floating,
which goes and ties presentation back into the HTML.

--
Michael F. Stemper
#include <Standard_Discl aimer>
This sentence no verb.

Jul 21 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
4559
by: Mike Irwin | last post by:
Here's the test page: <!doctype html public "-//w3c//dtd xhtml 1.0 strict//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head><title>Test</title> <style type="text/css"> #Wrapper { width: 750px;
5
2990
by: Trent | last post by:
I was experimenting with two column layouts, and at one point wrote the code listed at the end of this message. IE and Mozilla have two entirely different interpretations of what it does. In IE6, the c1 divs are all lined up along the left side of the page. The c2 divs are lined up along the right side of the page. Both columns start at...
3
5002
by: Philip | last post by:
I am trying to make a bunched of left-floated divs that will be contained in a larger div. the floated divs all contain a left-floated img and text of varying sizes. If I don't set a height (or height:auto) the larger div doesn't seem to see the nested divs, and they spill out the bottom. IE seems to automatically resize the larger div as...
3
2271
by: yawnmoth | last post by:
float, among other css attributes, is not working as i'd expect it to on the following webpage: http://www.frostjedi.com/terra/dev/test.html In Internet Explorer, there's a space between the yellow div and the light blue div that I don't believe should be there. Also, the red div has a height that is quite clearly more than the 1px that...
8
3083
by: kaeli | last post by:
I have had a little free time lately to revisit a problem I have with the 3 column layout plus a header and footer. See this example: http://glish.com/css/7.asp There is a header and 3 columns. Pretend there's a footer at the bottom, too. :) Here are the issues I have been unable to solve without tables _somewhere_
2
4400
by: Remi Villatel | last post by:
Hi there, I have following CSS definitions: div.limits { margin: 0 20px 0 20px; } div.halfleft { float: left; left: 0; width: 50%;
0
2122
by: atarumorooka | last post by:
Hello, yes..it must be hard to try and help someone else coding but today is a full week of sadness and stress for IE CSS rendering and I need your help. Here you have a link that looks nice with Opera and Firefox but it shows problems with IE6 (I've no idea with IE7): http://www.fitcisl.it/fit/index.asp Here I copy the css code with the...
2
1619
by: Liam Gibbs | last post by:
Hello everyone, This will be my third time posting this, but for some reason, my message isn't get through to the newsgroup, even after hours of waiting. So here goes again. I'm having huge problems with a site I'm creating for a church. I'm trying to use DIVs and SPANs for the layout, not a table, but I'm honestly thinking of just going...
3
4905
by: Nitinkcv | last post by:
Hi all, Im trying to do the following: Have 3 divs which are placed side by side. each has a two links 'left' and 'right'. Say on click of the 'left' hyperlink of the 2nd div(middle), the 1st div should take the place of the middle div, while the middle one should take the place of the 1st place. I'm using the prop offsetLeft, however...
0
7692
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7601
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8117
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7962
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6274
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5496
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5217
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
1
1207
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
931
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.