Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Floating Lists around Images

Status
Not open for further replies.

birgi

Technical User
Jan 17, 2003
20
Hi there, I'm Andrew,

So I had one of those professional slicing services and I need to troubleshoot something.


In the main column of content, I want the text to float around the image (bullets and all) instead of starting the next paragraph below the image.

Also if you wouldn't min, do you think this is good/clean CSS? or not-so-much? (why)
 
To keep it simple,

Code:
<img src="images/photo-home.jpg" width="184" height="150" [COLOR=red]style="float:left;"[/color] />We are determined to exceed all of


However, I don't really like the size attributes on the image. Personally I tend not to bother with them. If you need to size the image use CSS.

You might like to give the image an ID to apply styling to it. Or do as I sometimes do and create a class for floating images.

CSS:
img.right {
float:right;
margin-left:8px;
}

img.left {
float:left;
margin-right:8px;
}


If, however it's just this one image then using an inline style is acceptable I guess.

The markup, doesn't validate and it could certainly be optimised. Just fix the validation errors then leave it alone, it's fine.

--
Tek-Tips Forums is Member Supported. Click Here to donate

<honk>*:O)</honk>

Tyres: Mine's a pint of the black stuff.
Mike: You can't drink a pint of Bovril.


 
Thanks for that!

I tried each method, and nothing is working.

Something else is interfering with the ability to float. The paragraph/lists/headings below just wont move up around the image.

You can check the page again, as I'm now using your inline suggestion.

How can I get the text below the first paragraph to move up?
 
What is not allowing the floats is the fact that all your paragraphs are floated too. Since paragraphs have good amount of text within them (enough to reach the full width of their container) there is simply not enough space for them to float next to the image. That is why they float below it.

I suggest you remove the css rule that floats all paragraphs.

___________________________________________________________
[small]Do something about world cancer today: Comprehensive cancer control information at PACT[/small]
 
I'm so frustrated I want to stab my eyes out! lol

I removed the float rules from everything in my "box2" div.

Yet the text still refuses to float for us. Any ideas?

Thanks
 
It's moatly because the image is inside the 1st paragraph.

All of the paragraphs have a fixed width which won't allow them to float beside each other (within a column of the same width).

Greg
"Personally, I am always ready to learn, although I do not always like being taught." - Winston Churchill
 
(i also took the image outside the paragraph)

The more specific your solution, the better! As I am CSS challenged.
 
(i also took the image outside the paragraph)
No. This is an image outside the paragraph (tested - works)

Code:
[COLOR=blue]<img src="images/photo-home.jpg" />[/color]<p style="float: left; width: auto;">We are 
determined to exceed all of your expectations, regardless of the task.</P>
<P style="float: left; width: auto;">Our well-crafted and tested protocols return disabled employees to the 
workplace earlier than expected to the benefit of both employee and 
organization. </P>
Your code has (or had earlier) widths assigned to the paragraphs, so there was not enough room to float them in the column. I have overridden that with inline styles to demonstrate a working solution. I would not likely use inline styles in a final solution - I would rewrite your overly complex css to accomodate this.



Greg
"Personally, I am always ready to learn, although I do not always like being taught." - Winston Churchill
 
In your CSS you have:
Code:
#content .column1 p {
[!][s]float: left;[/s][/!]
line-height: 15px;
margin: 0pt;
padding: 15px 10px 0pt 15px;
width: 434px;
}
Remove the highlighted part.

___________________________________________________________
[small]Do something about world cancer today: Comprehensive cancer control information at PACT[/small]
 
Vragabond, doesn't he have to remove the width and keep the float if he wants to float the text?
(or use width:auto)

Or am I missing the intent here? (which happens often enough)

Greg
"Personally, I am always ready to learn, although I do not always like being taught." - Winston Churchill
 
No, actually he doesn't. Because as you know, paragraphs, if not specified differently will be at 100% width. Therefore his width of whatever it is will work as well.

It won't work together with float however. When you float elements, the width switches from 100% to auto or in OP's case, the specified 434px. Float will mean that paragraphs will attempt to float next to other elements if space. Since they are about as wide as the container, both things won't float. You can float a picture or paragraph, but not both. If you do both, then their combined widths cannot supersede that of the container.

OP is already floating the image, so he should not float the paragraphs as well.

But as for the width or no width question. When there's one floated element next to another non-floated, the floated element will float above part of the non-floated element and cover its background, borders and such but not its contents. The contents will wrap around the floated item. You can see that clearly by adding the background color and borders to the non-floated element. You will see that they will lie underneath the floated element.

___________________________________________________________
[small]Do something about world cancer today: Comprehensive cancer control information at PACT[/small]
 
Thanks for the banter! You really helped me figure it out.

Do you think the markup is ridiculously complex? I'm currently arguing with the slicing service because I'm totally dissatisfied with the CSS markup. Needlessly complicated?
 
Vrag, thanks for the explanation! Tunnel vision impedes my thought processes sometimes oftimes.

Greg
"Personally, I am always ready to learn, although I do not always like being taught." - Winston Churchill
 
That's the reason I charge alot more than a slicing service ;)

--
Tek-Tips Forums is Member Supported. Click Here to donate

<honk>*:O)</honk>

Tyres: Mine's a pint of the black stuff.
Mike: You can't drink a pint of Bovril.


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top