Welcome to MobyThreads.com!
FAQFAQ      ProfileProfile    Private MessagesPrivate Messages   Log inLog in
All support for the MobyThreads Threaded phpBB MOD can now be found on welsolutions at this forum

Floating an image

 
   Web Hosting and Web Master Forums (Home) -> Webmaster RSS
Next:  affiliate programs/networks  
Author Message
usenet

External


Since: Sep 14, 2004
Posts: 1119



(Msg. 1) Posted: Wed Aug 11, 2004 9:05 pm
Post subject: Floating an image
Archived from groups: alt>www>webmaster (more info?)

Folks,

How come, when I have a division with an image floated in it the division
doesn't resize to accommodate the image? Eg.

<div style="border: 1px solid red;">
<img ... style="float: left;" />
</div>

With the above code, I get a thin red line with an image displayed on the
left below it. Yet I would expect to see a box the same height (~) as the
image with a red border enclosing the image. Why is this not the case, and
how can I make it so?

Forgive me if this is something I should know already, but damn I am tired
today!

--
Dylan Parry
http://webpageworkshop.co.uk - FREE Web tutorials and references

'I am a Bear of Very Little Brain, and long words bother me.' -- A A Milne

 >> Stay informed about: Floating an image 
Back to top
Login to vote
spam19

External


Since: May 08, 2004
Posts: 952



(Msg. 2) Posted: Wed Aug 11, 2004 9:05 pm
Post subject: Re: Floating an image [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On Wed, 11 Aug 2004 18:05:44 +0100, Dylan Parry <usenet.RemoveThis@dylanparry.com>
wrote:

 > Folks,
 >
 > How come, when I have a division with an image floated in it the division
 > doesn't resize to accommodate the image? Eg.
 >
 > <div style="border: 1px solid red;">
 > <img .. style="float: left;" />
 > </div>
 >
 > With the above code, I get a thin red line with an image displayed on the
 > left below it. Yet I would expect to see a box the same height (~) as the
 > image with a red border enclosing the image. Why is this not the case,
 > and how can I make it so?

This is because Mozilla-based browsers wrongly treat floated elements like
absolutely positioned elements, pulling them completely out of the content
that surrounds them and placing them elsewhere. Thus the dimensions of
the floated element don't count towards the height of the box.

I fix this (explained in my min-height hack) with a 1px high div with a
clear:both; property. This div slips under the floated image and gives
the containing box something further down to enclose.

Grey

--
The technical axiom that nothing is impossible sinisterly implies the
pitfall corollory that nothing is ridiculous.
- <a style='text-decoration: underline;' href="http://www.greywyvern.com" target="_blank">http://www.greywyvern.com</a> - Orca Knowledgebase: Completely CSS styleable
Knowledgebase/FAQ system<!-- ~MESSAGE_AFTER~ -->

 >> Stay informed about: Floating an image 
Back to top
Login to vote
usenet

External


Since: Sep 14, 2004
Posts: 1119



(Msg. 3) Posted: Wed Aug 11, 2004 10:17 pm
Post subject: Re: Floating an image [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Engaging mouth before brain, GreyWyvern wrote:

 > This is because Mozilla-based browsers wrongly treat floated elements
 > like absolutely positioned elements, pulling them completely out of the
 > content that surrounds them and placing them elsewhere. Thus the
 > dimensions of the floated element don't count towards the height of the
 > box.

It also appears that it affects Opera sporadically. It doesn't seem to be
an issue on your hack page, but in my application it does :s

 > I fix this (explained in my min-height hack) with a 1px high div with a
 > clear:both; property. This div slips under the floated image and gives
 > the containing box something further down to enclose.

Cheers, that kinda works, although I chose to use a <br /> instead.

Thanks Wink

--
Dylan Parry
<a style='text-decoration: underline;' href="http://webpageworkshop.co.uk" target="_blank">http://webpageworkshop.co.uk</a> - FREE Web tutorials and references

'I am a Bear of Very Little Brain, and long words bother me.' -- A A Milne<!-- ~MESSAGE_AFTER~ -->
 >> Stay informed about: Floating an image 
Back to top
Login to vote
spambouncer1

External


Since: Apr 15, 2004
Posts: 43



(Msg. 4) Posted: Fri Aug 13, 2004 10:38 am
Post subject: Re: Floating an image [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

"Dylan Parry" <usenet RemoveThis @dylanparry.com> wrote in message
news:pan.2004.08.11.18.17.14.247469@dylanparry.com...
 > Engaging mouth before brain, GreyWyvern wrote:
 >
  > > This is because Mozilla-based browsers wrongly treat floated elements
  > > like absolutely positioned elements, pulling them completely out of the
  > > content that surrounds them and placing them elsewhere. Thus the
  > > dimensions of the floated element don't count towards the height of the
  > > box.
 >
 > It also appears that it affects Opera sporadically. It doesn't seem to be
 > an issue on your hack page, but in my application it does :s
 >
  > > I fix this (explained in my min-height hack) with a 1px high div with a
  > > clear:both; property. This div slips under the floated image and gives
  > > the containing box something further down to enclose.
 >
 > Cheers, that kinda works, although I chose to use a <br /> instead.
 >


I came up with an extra empty 1px division, as did Brian. I think you may
run into semantic problems by systematically using <br />.

--
"... they're all looking backwards over each other's shoulder."
(MIKE SMITH) Eurosport

<a style='text-decoration: underline;' href="http://www.private-eye.co.uk" target="_blank">http://www.private-eye.co.uk</a><!-- ~MESSAGE_AFTER~ -->
 >> Stay informed about: Floating an image 
Back to top
Login to vote
usenet

External


Since: Sep 14, 2004
Posts: 1119



(Msg. 5) Posted: Fri Aug 13, 2004 5:59 pm
Post subject: Re: Floating an image [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Engaging mouth before brain, Mak wrote:

 > I came up with an extra empty 1px division, as did Brian. I think you may
 > run into semantic problems by systematically using <br />.

Yes, I eventually changed to the division method as the break was causing
a couple of problems in Opera. Mainly cosmetic though; extra large margin
at the bottom of the page, but I couldn't see any semantic problems
present when using a text-only browser.

--
Dylan Parry
<a style='text-decoration: underline;' href="http://webpageworkshop.co.uk" target="_blank">http://webpageworkshop.co.uk</a> - FREE Web tutorials and references

'I am a Bear of Very Little Brain, and long words bother me.' -- A A Milne<!-- ~MESSAGE_AFTER~ -->
 >> Stay informed about: Floating an image 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
Image in a <TD> - Hi, I'm sure this must be easy, but how do I get two images inside a single <TD> and force on to the left of the td and 1 to the right of the <TD> So the effect is <TD>Image1 Image2</TD> Thanks for any help zeebop

Image Problem - Further to my image problem, Can anyone tell me why a very small percentage of people can't view the jpegs on a site. Is there anything wrong with this HTML?: <img src='../adimages/309thumb.jpg' alt='' border=0> I have had about 5 people saying th...

Image effects - Hi all, I would like to find out, how to "cut" out an image into a circle. Then add effects later like shadow embossing etc with Photoshop 7. Also I would like to add graphical frame/borders to some of my pictures. Any ideas? I would like to c...

Image Maps - I know so many people are using image maps now days to create their rollover locations. How dependable are they? Do you guys oppose them? -- Sharif Tanvir Karim http://www.aftermathstudios.com

Image protection - Hi folks ... wonder if I could pick a few brains out there.. I have been asked to protect bandwidth on an image heavy "Anime" site - the owner complaining that people are refering to the images and stealing her bandwidth. (shes not bothered ab...
   Web Hosting and Web Master Forums (Home) -> Webmaster All times are: Pacific Time (US & Canada) (change)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]