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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CSS 4.01 strict question

Status
Not open for further replies.

Wholsea

Programmer
Jun 16, 2004
138
US
Sorry, I couldn't find this forum yesterday when I posted this question origionally in a .NET forum...

Trying to build an elastic DIV box with a minimum width of 25%.

Without the doctype definition, we can do the following hack to get minwidth to work in all browsers:

min-width:25%;
width:auto !important;
width:25%;

But with the doctype definition, the only directive I can get to stick is "width:25%;" which forces the div to 25% anything bigger than that bleeds over into the rest of the page content.

Otherwise the div expands to 100% of the available space.

The following is a quick mock up page that can be played with to see what is going on. Basically, we should be able to set the minimum width of the div to 1px and the div should grow to be as big as the content within the div.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "" title="
<style>
.smallDialog{
border:solid 1px;
min-height:50px;
height:auto !important;
height:50px;
width:25%;
}
</style>

<div class="smallDialog">
<select>
<option>blah blah blah blah blah blah blah blah blah blahb</option>
</select>
This is a big test This is a big test This is a big test This is a big test This is a big test
</div>


ASP, VB, VBS, Cold Fusion, SQL, DTS, T-SQL, PL-SQL, IBM-MQ, Crystal Reports, Crystal Enterprise
 
If you are just trying to make the div big enough for what's in it and no bigger then simply float it.

You can also apply a min-width for compliant browsers to stop the div collapsing smaller than it's content (so long as you specify a width greater than the width of the contained elemetns).

By default IE6 will increase the width to accomodate it's contents anyway and will be restricted to a minimum value as specified by width.

--
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