CSS Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsWeb DesignCSS Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old July 22nd, 2004, 08:47 PM
Garrett_44 Garrett_44 is offline
rubbish in javascript
Dev Shed Novice (500 - 999 posts)
 
Join Date: Feb 2001
Location: London
Posts: 683 Garrett_44 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 41 m 39 sec
Reputation Power: 8
making a div have a minimal size or expand

Hi

Trying to make a box (with a div and css to control it) that will fit around an image and some text. The image is 90 x 90 pixels and should have a margin of 10 pixels around it so I want my box to be a minimum of 110 pixels high - heres the catch, the text is never the same length its actually printed into the page from some php so the box needs to never go smaller than the image and its margins however if the text is of greater height than those the box needs to expand. This is what I have so far...


<style>
.floatimage
{
float: left;
padding: 1px;
margin-right: 10px;
background-color: #CCCCCC;
}

.floatbox
{
width: 380px;
padding: 10px;
background-color: #ff0000;
height: 112px;
}
</style>

<div class="floatbox">
<div class="floatimage"><img alt="" src="image/icons/icon.php" /></div>
<p>
The float property allows other text to fit itself around a box. This is
particularly useful with images, but it can be used in any way.
</p>
<p>
I've created this example with enough text that it should wrap around
the above floated paragraph. Let's keep going to see what happens.
Does it really do what I think it should do?
</p>
</div>


but when i give the box a height its fixed and when i don't it can go smaller than the image - is there a way to do this?

Thanks in advance

a+
gar

Reply With Quote
  #2  
Old July 22nd, 2004, 09:55 PM
kk5st's Avatar
kk5st kk5st is offline
Thanks Johnny Hart (BC) R.I.P.
Dev Shed Demi-God (4500 - 4999 posts)
 
Join Date: May 2003
Location: Dallas
Posts: 4,672 kk5st User rank is Brigadier General (60000 - 70000 Reputation Level)kk5st User rank is Brigadier General (60000 - 70000 Reputation Level)kk5st User rank is Brigadier General (60000 - 70000 Reputation Level)kk5st User rank is Brigadier General (60000 - 70000 Reputation Level)kk5st User rank is Brigadier General (60000 - 70000 Reputation Level)kk5st User rank is Brigadier General (60000 - 70000 Reputation Level)kk5st User rank is Brigadier General (60000 - 70000 Reputation Level)kk5st User rank is Brigadier General (60000 - 70000 Reputation Level)kk5st User rank is Brigadier General (60000 - 70000 Reputation Level)kk5st User rank is Brigadier General (60000 - 70000 Reputation Level)kk5st User rank is Brigadier General (60000 - 70000 Reputation Level)kk5st User rank is Brigadier General (60000 - 70000 Reputation Level)kk5st User rank is Brigadier General (60000 - 70000 Reputation Level) 
Time spent in forums: 1 Month 3 Days 14 h 56 m 21 sec
Reputation Power: 687
Code:
—styles—

.floater {
    float: left;
    width: 90px;  /*a float must have a width*/
    padding: 1px;
    margin-right: 10px;
    background-color: #ccc;
    }

.boxholdingfloat {
    width: 380px;
    padding: 10px;
    background-color: #f00;
    }

.clearing {
    font-size: 0;
    clear: both;
    }

—html—

<div class="boxholdingfloat">
  <img class="floater" alt="" src="image/icons/icon.php" />
  <p>The float property allows other text to fit itself around a box. This is
     particularly useful with images, but it can be used in any way.</p>
  <p>I've created this example with enough text that it should wrap around
     the above floated paragraph. Let's keep going to see what happens.
     Does it really do what I think it should do?</p>
<p class="clearing">&nbsp;</p>
</div>

Use the clearing class to force the in-the-flow div to drop down to clear the float. If content would clear it anyway, no problema. Don't give the float holder a height, and it will naturally grow as needed for content. If IE has a brainfart, make the floatholder {position:relative;}

cheers,

gary
__________________
There are those who manage to build a web site without knowing what they're doing; thereby proving to themselves they do, indeed, know what they're doing.

My html and css workshop, demos and tutorials.
Ask a better question, get a better answer.

Last edited by kk5st : July 22nd, 2004 at 09:58 PM.

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignCSS Help > making a div have a minimal size or expand


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT