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

why does this css wrap?

Status
Not open for further replies.

iostream71

Programmer
Mar 13, 2002
229
US
<html>
<head>
<style type=&quot;text/css&quot;>
.block{
background-color:red;
width:200px;
height:200px;

}

.header{
background-color:gray;
width:10px;
padding:3px 3px 3px 3px;
}

.content{
background-color:blue;
width:100%;
height:100%;
padding:10px 10px 10px 10px;
}
</style>
</head>

<body bgcolor=&quot;#FFFFFF&quot; text=&quot;#000000&quot;>
<!-- outer block -->
<div class=&quot;block&quot;>
<div class=&quot;header&quot;>header</div>
<div class=&quot;content&quot;>

<!-- inner block -->
<div class=&quot;block&quot;>
<div class=&quot;header&quot;>sub header</div>
<div class=&quot;content&quot;>sub content</div>
</div>

</div>
</div>
</body>
</html>


if you look at it, you'll see that the header in the &quot;inner block&quot; wraps (what i don't want), while the one in the &quot;outer block&quot; doesn't. why is this, and how can i fix?
 
.header{
background-color:gray;
width:10px;
padding:3px 3px 3px 3px;
}

This is set to 10px. Therefore it streches to fit it's content. But that is the width that is now set. Try setting it at 150px then it will not wrap. There may be a css = to nowrap???? DeZiner
Never be afraid to try something new.
Remember that amateurs built the Ark.
Professionals built the Titanic
 
no, i did that on purpose. i set it extra small, so that any text could fit in there, and the padding would force it to have a 3 pixel border, no matter the text.

why does it wrap in the first case, but not the second...that's what i don't understand
 
found out why it does. it's because in the first example, it's on word; the second, it's multiple words. i feel stupid now =P
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top