Advanced Search Usage Terms Submit Contact
Dynamic Drive CSS Library
 
CSS Library
Submit an original CSS code
CSS Layouts
Web Graphics
Online Tools:

Advertise Here

CSS Library: Image CSS: Here

Floating image with no text wrap

Author: Dynamic Drive

By default, floating an image causes the surrounding text to wrap around it, such in in the below example:

A safari park is a large nature reserve intended for safari tours and encounters with rare wildlife. They are common in Africa, but many exist elsewhere, including popular parks in England. People who wish to see animals in their natural state will love a trip to the safari.

However, sometimes you may want a different effect whereby the image floats, yet the surrounding content do NOT wrap around the image. This can be accomplished through the familiar "float" attribute, combined with "margins", while taking into account IE'6 dreadful "3px text-jog bug". The result is:

A safari park is a large nature reserve intended for safari tours and encounters with rare wildlife. They are common in Africa, but many exist elsewhere, including popular parks in England. People who wish to see animals in their natural state will love a trip to the safari.

The CSS:

The HTML:

Code Info

Rate this code:

Date Posted: 05/02/2006

Revision History: None

Usage Terms: Click here

Your Comments (71)

Got a question or need help customizing this CSS code? Post it in the CSS Forums. If you have a comment or suggestion instead, post it in the comments section below.

Comment Pages 2 of 7 pages  <  1 2 3 4 >  Last »

Yes what Krazy3 said is the best way. Instead of adding all that code just add 2 lines on and you get the same effect. If you want to set border limits its just a few more lines

Style.css
.imagebox {
border-left: 1px; border-right: 1px; border-bottom: 1px; border-top: 1px;
width: 300px;
height: 300px;
}

.thumbnail_left {
width: 100px;
heigh: 100px;
float: left;
margin-left: 3px;
}

Index.html
<div id="imagebox">
image_location.gif
</div>

That will do everything that is given above.
Posted by IamShipon1988 on 04/03, 02:17 PM
I use this kind of code to get an image inline of text:
<img src='image.png' alt='some text' style='display: inline; float: left; padding: 3px' /> 

And it works perfectly fine. Or maybe I didn't understand what this is supposed to be. :)
Posted by Lorin on 09/10, 12:01 PM
pls show the next page .
Posted by partha on 09/16, 11:24 PM
Wouldn't a table with 2 columns do the same thing?
Posted by scott on 11/07, 08:13 AM
Re-Created the provided css code so it displays photos on the left and text on the right with a box around the whole thing. Need to alternate the photos (Right and Left)

Also added a textbox on the top of the page, to act as a header. Need to have entry (Form) code. Is this possible in css? New to css and am analyzing as I learn.

Will be happy to share my code. By the way, I was having a problem with wrapping the text within the box I created. Used float: left; to make the wrap happen.

Appreciate any suggestions. Thanks

Tom Kennedy
Posted by Tom Kennedy on 12/18, 11:00 AM
I tried to add asp variable to place where the text comes, but variable text goes outside box.

<p><%=txtDescription%>static text</p>

The static text the otherhand works OK, but I need to use a variable.
Posted by marksu on 12/31, 09:37 AM
Never mind my bad. It works wery nicely thanks.
Posted by marksu on 01/02, 04:41 AM
seems not to work to well..
Posted by duziek on 03/08, 12:34 PM
Thats it! thanks for that, I was looking a tutorial like that...
Posted by Forumistan on 03/13, 05:19 PM
It wont work for me. anyone know why ??
Posted by James N on 03/16, 03:57 PM

Comment Pages 2 of 7 pages  <  1 2 3 4 >  Last »

Commenting is not available in this weblog entry.
Copyright 2006-2011 Dynamic Drive Read our Usage Terms before using any of the CSS codes.