Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old July 20th, 2005, 09:27 PM
Tony Benham
Guest
 
Posts: n/a
Default Div not sized correctly if containing image

I have a main div on a page that contains some text plus an img which is
floated right, causing the image to be placed on the right of the div with
the text on the left. However the height of the div sizes to fit the text
but not the image. I want the div to size in height to fit the height of the
image.
After searching google I found a suggestion to add
<div style="clear:right"></div> at the bottom of the containing div just
before the ending </div>

This seems to work ok in ie (although it screws up the left margin of the
containing div for some reason) but in mozilla1.4/netscape 7.1 it doesn't
have any effect.

Is there another technique I could use ?

Regards

Tony




  #2  
Old July 20th, 2005, 09:27 PM
Kris
Guest
 
Posts: n/a
Default Re: Div not sized correctly if containing image

In article <blei8b$bc3fg$1@ID-170918.news.uni-berlin.de>,
"Tony Benham" <tonyb@kerrisway.freeserve.co.uk> wrote:
[color=blue]
> I have a main div on a page that contains some text plus an img which is
> floated right, causing the image to be placed on the right of the div with
> the text on the left. However the height of the div sizes to fit the text
> but not the image. I want the div to size in height to fit the height of the
> image.
> After searching google I found a suggestion to add
> <div style="clear:right"></div> at the bottom of the containing div just
> before the ending </div>
>
> This seems to work ok in ie (although it screws up the left margin of the
> containing div for some reason) but in mozilla1.4/netscape 7.1 it doesn't
> have any effect.
>
> Is there another technique I could use ?[/color]

I often use <br class="break">
..break { clear: both; }

The real method of course is:
img { float: right; }
img:after { clear: right; }

But MSIE does not support the :after pseudo-selector.

--
Kris
kristiaan@xs4all.netherlands (nl)
  #3  
Old July 20th, 2005, 09:27 PM
Brian
Guest
 
Posts: n/a
Default Re: Div not sized correctly if containing image

Tony Benham wrote:[color=blue]
> I have a main div on a page that contains some text plus an img which is
> floated right, causing the image to be placed on the right of the div with
> the text on the left. However the height of the div sizes to fit the text
> but not the image.[/color]

That's correct behavior.
[color=blue]
> I want the div to size in height to fit the height of the
> image.
> After searching google I found a suggestion to add
> <div style="clear:right"></div> at the bottom of the containing div just
> before the ending </div>
>
> This seems to work ok in ie (although it screws up the left margin of the
> containing div for some reason) but in mozilla1.4/netscape 7.1 it doesn't
> have any effect.[/color]

That should work; in fact, I have used it with success in Mozilla
1.3/win2k.

Check your html and css for errors. Then, supply a url.

--
Brian
follow the directions in my address to email me

  #4  
Old July 20th, 2005, 09:27 PM
Tony Benham
Guest
 
Posts: n/a
Default Re: Div not sized correctly if containing image

"Brian" <usenet1@mangymutt.com.invalid-remove-this-part> wrote in message
news:hBCeb.474768$Oz4.302357@rwcrnsc54...[color=blue]
> Tony Benham wrote:[color=green]
> > I have a main div on a page that contains some text plus an img which is
> > floated right, causing the image to be placed on the right of the div[/color][/color]
with[color=blue][color=green]
> > the text on the left. However the height of the div sizes to fit the[/color][/color]
text[color=blue][color=green]
> > but not the image.[/color]
>
> That's correct behavior.
>[color=green]
> > I want the div to size in height to fit the height of the
> > image.
> > After searching google I found a suggestion to add
> > <div style="clear:right"></div> at the bottom of the containing div just
> > before the ending </div>
> >
> > This seems to work ok in ie (although it screws up the left margin of[/color][/color]
the[color=blue][color=green]
> > containing div for some reason) but in mozilla1.4/netscape 7.1 it[/color][/color]
doesn't[color=blue][color=green]
> > have any effect.[/color]
>
> That should work; in fact, I have used it with success in Mozilla
> 1.3/win2k.
>
> Check your html and css for errors. Then, supply a url.
>[/color]
Brian,
Both css & html are css2.0, xhtml1.0 valid respectively.
http://www.woodleyzebrasfc.com/testpic.html
contains an example. This is sort of ok in ie6, apart from margin problem on
left, but not in netscape7.1/moz1.4 ?
Regards
Tony



  #5  
Old July 20th, 2005, 09:28 PM
Brian
Guest
 
Posts: n/a
Default Re: Div not sized correctly if containing image

Tony Benham wrote:[color=blue]
>
> http://www.woodleyzebrasfc.com/testpic.html[/color]

operation timed out. server problems?

--
Brian
follow the directions in my address to email me

  #6  
Old July 20th, 2005, 09:28 PM
Lauri Raittila
Guest
 
Posts: n/a
Default Re: Div not sized correctly if containing image

In article <blhdcq$bd9a9$1@ID-170918.news.uni-berlin.de>, Tony Benham
wrote:[color=blue]
> Brian,
> Both css & html are css2.0, xhtml1.0 valid respectively.
> http://www.woodleyzebrasfc.com/testpic.html
> contains an example. This is sort of ok in ie6, apart from margin problem on
> left, but not in netscape7.1/moz1.4 ?[/color]

"Works" with Opera 7.20, after I use fullscreen to get text and image
side by side. It seems to make extra line at the bottom though.

The reason it don't work on Mozilla is collapsing margins, I think. I'm
not at all sure if W3 people intended collapsing happen here, but
according to spec it should IIRC. Add some border, padding, or content to
that extra div or borrom-border or -padding to container. For example,
purple bottom border.

BTW, the heading image slicing I promised to you is still not ready.
http://www.student.oulu.fi/~laurirai...img_after.html
The anti-aliasing is quick and dirty, and it is not tested much - and
some of the images aren't optimized. The effect that you use on your
current site about having black on right expand is propably impossible on
IE.


--
Lauri Raittila <http://www.iki.fi/lr> <http://www.iki.fi/zwak/fonts>
Saapi lähettää meiliä, jos aihe ei liity ryhmään, tai on yksityinen
tjsp., mutta älä lähetä samaa viestiä meilitse ja ryhmään.

  #7  
Old July 20th, 2005, 09:28 PM
Tony Benham
Guest
 
Posts: n/a
Default Re: Div not sized correctly if containing image

"Brian" <usenet1@mangymutt.com.invalid-remove-this-part> wrote in message
news:xJYeb.202660$mp.124297@rwcrnsc51.ops.asp.att. net...[color=blue]
> Tony Benham wrote:[color=green]
> >
> > http://www.woodleyzebrasfc.com/testpic.html[/color]
>
> operation timed out. server problems?
>
> --
> Brian
> follow the directions in my address to email me
>[/color]

Brian,
Portland are back up at a sensible speed again if you want to have a look ?
Cheers
Tony



  #8  
Old July 20th, 2005, 09:28 PM
Brian
Guest
 
Posts: n/a
Default Re: Div not sized correctly if containing image

Tony Benham wrote:[color=blue]
>[color=green][color=darkred]
>>> http://www.woodleyzebrasfc.com/testpic.html[/color][/color]
>
> Portland are back up at a sensible speed again[/color]

Indeed.
[color=blue]
> if you want to have a look ?[/color]

I see no border in the div. How do you know the div's height isn't
affected? Put borders around things -- bright borders -- to
troubleshoot things. You know this better than I do. I'm looking at
it for the first time. (BTW, that's the actress from "Buffy," right?
It was my sister's favorite tv show.)

If you are sure it is not working, try
<div style="clear: left">&nbsp;</div>
but, I must admit, I use an empty div for this on my pages, and it
works, Moz 1.3/Win2k. (?)


--
Brian
follow the directions in my address to email me

  #9  
Old July 20th, 2005, 09:28 PM
Tony Benham
Guest
 
Posts: n/a
Default Re: Div not sized correctly if containing image

> I see no border in the div. How do you know the div's height isn't[color=blue]
> affected? Put borders around things -- bright borders -- to
> troubleshoot things. You know this better than I do. I'm looking at
> it for the first time. (BTW, that's the actress from "Buffy," right?
> It was my sister's favorite tv show.)[/color]

Yes it's Alyson Hannigan from Buffy. I just used her for an example pic.
She's quite cute.
[color=blue]
> If you are sure it is not working, try
> <div style="clear: left">&nbsp;</div>
> but, I must admit, I use an empty div for this on my pages, and it
> works, Moz 1.3/Win2k. (?)[/color]
adding &nbsp ; fixes it for mozilla. I'll try adding a
border/margin/padding as well as Lauri suggested.

Cheers
Tony


  #10  
Old July 20th, 2005, 09:28 PM
The Plankmeister
Guest
 
Posts: n/a
Default Re: Div not sized correctly if containing image

> This seems to work ok in ie (although it screws up the left margin of the[color=blue]
> containing div for some reason) but in mozilla1.4/netscape 7.1 it doesn't
> have any effect.[/color]


Check this out... I'm surprised it works for you in IE! I have the same
problem on my site but I have to set "background : none" for the floatholder
to get it to work...

http://www.positioniseverything.net/.../peekaboo.html



  #11  
Old July 20th, 2005, 09:28 PM
Tony Benham
Guest
 
Posts: n/a
Default Re: Div not sized correctly if containing image

"Lauri Raittila" <lauri@raittila.cjb.net> wrote in message
news:MPG.19e69eba79688dc4989c8d@news.cis.dfn.de...[color=blue]
> In article <blhdcq$bd9a9$1@ID-170918.news.uni-berlin.de>, Tony Benham
> wrote:[color=green]
> > Brian,
> > Both css & html are css2.0, xhtml1.0 valid respectively.
> > http://www.woodleyzebrasfc.com/testpic.html
> > contains an example. This is sort of ok in ie6, apart from margin[/color][/color]
problem on[color=blue][color=green]
> > left, but not in netscape7.1/moz1.4 ?[/color]
>
> "Works" with Opera 7.20, after I use fullscreen to get text and image
> side by side. It seems to make extra line at the bottom though.
>
> The reason it don't work on Mozilla is collapsing margins, I think. I'm
> not at all sure if W3 people intended collapsing happen here, but
> according to spec it should IIRC. Add some border, padding, or content to
> that extra div or borrom-border or -padding to container. For example,
> purple bottom border.[/color]

Hi Lauri,
I added padding : 1px ; to the extra div which fixes the problem, as does
adding a &nbsp; into the div.
Thanks for the tip.

[color=blue]
> BTW, the heading image slicing I promised to you is still not ready.
> http://www.student.oulu.fi/~laurirai...img_after.html
> The anti-aliasing is quick and dirty, and it is not tested much - and
> some of the images aren't optimized. The effect that you use on your
> current site about having black on right expand is propably impossible on
> IE.
>[/color]
I guess if the white-black part of the image floated right and white is
filled in on the left that might work ok ?

Thanks anyway
Tony


  #12  
Old July 20th, 2005, 09:28 PM
Lauri Raittila
Guest
 
Posts: n/a
Default Re: Div not sized correctly if containing image

In article <bljoil$d8jed$1@ID-170918.news.uni-berlin.de>, Tony Benham
wrote:[color=blue]
> "Lauri Raittila" <lauri@raittila.cjb.net> wrote in message
> news:MPG.19e69eba79688dc4989c8d@news.cis.dfn.de...[color=green]
> > In article <blhdcq$bd9a9$1@ID-170918.news.uni-berlin.de>, Tony Benham
> > wrote:[color=darkred]
> > > Brian,
> > > Both css & html are css2.0, xhtml1.0 valid respectively.
> > > http://www.woodleyzebrasfc.com/testpic.html
> > > contains an example. This is sort of ok in ie6, apart from margin[/color][/color]
> problem on[color=green][color=darkred]
> > > left, but not in netscape7.1/moz1.4 ?[/color]
> >
> > "Works" with Opera 7.20, after I use fullscreen to get text and image
> > side by side. It seems to make extra line at the bottom though.
> >
> > The reason it don't work on Mozilla is collapsing margins, I think. I'm
> > not at all sure if W3 people intended collapsing happen here, but
> > according to spec it should IIRC. Add some border, padding, or content to
> > that extra div or borrom-border or -padding to container. For example,
> > purple bottom border.[/color]
>
> Hi Lauri,
> I added padding : 1px ; to the extra div which fixes the problem, as does
> adding a &nbsp; into the div.
> Thanks for the tip.
>
>[color=green]
> > BTW, the heading image slicing I promised to you is still not ready.
> > http://www.student.oulu.fi/~laurirai...img_after.html
> > The anti-aliasing is quick and dirty, and it is not tested much - and
> > some of the images aren't optimized. The effect that you use on your
> > current site about having black on right expand is propably impossible on
> > IE.[/color][/color]

I think I was mistaken, I'll try more later. Needs propably couple of
empty spans though.
[color=blue]
> I guess if the white-black part of the image floated right and white is
> filled in on the left that might work ok ?[/color]

That would happen easiest by floating whole #top to right (might cause
some difference on MacIE though). I don't think that will look as nice
though. The current way (in IE) of streching white between logo and text
is IMHO nicer looking.

What way would you prefer?

--
Lauri Raittila <http://www.iki.fi/lr> <http://www.iki.fi/zwak/fonts>
Saapi lähettää meiliä, jos aihe ei liity ryhmään, tai on yksityinen
tjsp., mutta älä lähetä samaa viestiä meilitse ja ryhmään.

 

Bookmarks

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 Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles