Floating an image inside colour div bkground

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.



Go Back   Webforumz.com > Main Forums > Design Your Website > Web Page Design

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Aug 30th, 2006, 10:38
Junior Member
Join Date: Aug 2006
Location: Lancashire, UK
Age: 28
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
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 , I'd be glad for any advice, Thanks.
Reply With Quote

  #2 (permalink)  
Old Aug 30th, 2006, 13:49
moojoo's Avatar
Moderator
Join Date: Aug 2005
Location: Texas
Age: 31
Posts: 1,742
Blog Entries: 1
Thanks: 0
Thanked 17 Times in 17 Posts
Send a message via AIM to moojoo Send a message via MSN to moojoo Send a message via Yahoo to moojoo
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">&nbsp;</div>
</div>
__________________
The internet is just a fad.
http://www.mevans76.com
Last Blog Entry: Apps every Mac based web dev should consider (Jul 10th, 2008)
Reply With Quote
  #3 (permalink)  
Old Aug 30th, 2006, 20:29
Ryan Fait's Avatar
SuperMember

SuperMember
Join Date: May 2006
Location: Las Vegas
Posts: 3,786
Thanks: 0
Thanked 0 Times in 0 Posts
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;
Reply With Quote
  #4 (permalink)  
Old Aug 31st, 2006, 08:22
Junior Member
Join Date: Aug 2006
Location: Lancashire, UK
Age: 28
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Floating an image inside colour div bkground

Brill, Thanks guys.
Reply With Quote
Reply

Tags
floating, image, inside, colour, div, bkground

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Floating over text ihateasp Web Page Design 8 Dec 18th, 2007 08:16
[SOLVED] positioning something inside an image danny322 Web Page Design 3 Dec 5th, 2007 13:36
Floating with an image between columns? oya Web Page Design 2 Aug 27th, 2006 11:08
floating problems... gogogadgetearl Web Page Design 0 Jul 16th, 2005 04:25
Floating Without tables jcschott Web Page Design 3 Apr 19th, 2005 16:22


All times are GMT. The time now is 08:58.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43