provaands / 2004-08-14 23:36:
Question:
can I make so that word hellooooo..... remains all within to the div?
You have
<div style='width:100px; background:#99CCFF;'>
helloooooooooooooooooooooooooooooooooooooooooooooo ooooooooooooooooooo
</div>
You want
<div class="enclose"> hello....ooo </div>
with a style sheet rules
..enclose { min-width: 100px; }
* html .enclose { width: 100px; }
That is, you really want to use 'min-width' property. The latter
line is for MSIE which doesn't support 'min-width'. Fortunately it
implements 'width' incorrectly and it works just like 'min-width' is
supposed to work. In addition, MSIE has a CSS selector bug that
makes it to match "* html .enclose" selector with all elements that
have class "enclose". So only MSIE sees the 'width' rule.
If you care that some browsers do not support min-width and do not
have the same parser bug as MSIE and the page layout is too fragile
to take default of 'auto' for the 'width', then you could try
different rules instead:
..enclose { width: 100px; }
html>body .enclose { width: auto; min-width: 100px; }
This time we *undo* the incorrect 'width' setting with a rule that
has "too complex" selector for MSIE and friends that implement
'width' incorrectly. Hopefully every browser that understands this
selector also implements 'min-width'.
If you want to also support MSIE5 which has broken box model it gets
more complicated; if you have borders, paddings or margins, you have
to subract those from the 'width'...
If you really want to go through all of this and find out about
different browser bugs, here's a great place to start:
http://www.positioniseverything.net/
--
Mikko