Forum Moderators: not2easy

Message Too Old, No Replies

CSS - images and text wrap

just a quickie

         

edit_g

3:38 pm on Nov 25, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Does anyone have any ideas as to how to get text to wrap nicely around images using CSS. I'm currently using "float:left;" to get them to do it but then I have to position them using the margin-top and margin-left/right properties- which is time consuming and sketchy as to how it displays. Do any of you know a better option? Nick_W?

edit_g

4:13 pm on Nov 25, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Don't worry (delete this post if you like Mr. Mods) I got it by assigning position: relative to the image. :)

Nick_W

4:20 pm on Nov 25, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hey edit_g

I always float 'em. How'd you do it with position relative?

Nick

edit_g

4:29 pm on Nov 25, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hey Nick_W (and thanks)

Simple answer- I don't know. ;) I know it doesn't make any sense...

They just weren't displaying correctly (they were displaying on top of the text instead of letting the text wrap around them). So as a measure of desperation I put in position: position relative and they now display just fine. I think it may have had something to do with the text being only a little bit larger than the image it was trying to wrap around. But the float attribute along with the position relavive seems to have done the trick.

tedster

5:16 pm on Nov 25, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



they were displaying on top of the text instead of letting the text wrap around them

Were you also declaring display:block?
I've found that necessary to get a proper text wrap.

edit_g

5:27 pm on Nov 25, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I hadn't tried that- but I put it in now- it didn't seem to make a difference.

Here's the code (with the display: block- I've never seen that attribute b4):

<span class="is_contentBody">

<img src="images/myimage.jpg" border="1px" width="45" height="45" style="float: right; position: relative; top: 5px;margin-left:5px;display:block;">

I'm a bit of content short and stout. Here's my handle here's my snout. I'm a bit of content short and stout. Here's my handle here's my snout.

<a href="#" class="is_contentLink">Click here</a></span>

<edited for clarity>

Nick_W

5:30 pm on Nov 25, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Might have something to do with floating within an inline element.

If you replace the <span> for a div what do you get? -- I'm not certain but I think that will be more reliable....

Nick

edit_g

5:38 pm on Nov 25, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Just tried that- didn't seem to make a difference. Its ok though- it is displaying ok now. Thanks guys :)