This is a discussion on "Floating an image inside colour div bkground" within the Web Page Design section. This forum, and the thread "Floating an image inside colour div bkground are both part of the Design Your Website category.
|
|
|
|
|
![]() |
||
Floating an image inside colour div bkground
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
#1
|
|||
|
|||
|
Floating an image inside colour div bkground
Hi,
I wanted to make elements on a site more prominent by adding a background colour and border (creating a box) as a sort of feature. When I add an image into this 'feature' box and float it so it appears to the left if the image is longer than the text content in the box it overlaps the bottom of the box. I've tried to illustrate this below.... STYLE: #feature { background-color:#EEEEEE; border:1px solid #D7D7D7; padding:10px; } .floatL { float:left; padding:0px 10px 0px 0px; } CODE: <div id="feature"> img src="#.jpg" alt="#" width="80" height="61" border="0" class="floatL"> <p>Text content....</p> </div> Painfully simple I know |
|
#2
|
|||
|
|||
|
Re: Floating an image inside colour div bkground
Floated elements are not in the normal document flow. And thus it will overlap the box if the image is taller than the content. a quick fix would be to do something like:
.clearing {height:0; clear:both;} <div id="feature"> img src="#.jpg" alt="#" width="80" height="61" border="0" class="floatL"> <p>Text content....</p> <div class="clearing"> </div> </div>
Last Blog Entry: Apps every Mac based web dev should consider (Jul 10th, 2008)
|
|
#3
|
||||
|
||||
|
Re: Floating an image inside colour div bkground
You can also specify an exact height for #feature by adding this to its properties:
height: 71px; |
|
#4
|
|||
|
|||
|
Re: Floating an image inside colour div bkground
Brill, Thanks guys.
|
![]() |
| Tags |
| floating, image, inside, colour, div, bkground |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Floating over text | ihateasp | Web Page Design | 8 | Dec 18th, 2007 09:16 |
| [SOLVED] positioning something inside an image | danny322 | Web Page Design | 3 | Dec 5th, 2007 14:36 |
| Floating with an image between columns? | oya | Web Page Design | 2 | Aug 27th, 2006 12:08 |
| floating problems... | gogogadgetearl | Web Page Design | 0 | Jul 16th, 2005 05:25 |
| Floating Without tables | jcschott | Web Page Design | 3 | Apr 19th, 2005 17:22 |