3 replies [Last post]
homchz
Offline
Enthusiast
Last seen: 13 years 37 weeks ago
Joined: 2004-07-23
Posts: 77
Points: 0

is this normal

In order to pad my text with out making seperate classes I have had to reduce my box width to make up for the padding (or margin).

While i give me the desired effect is this this the right way to do it?

.navbox{
	background-color:#DFDFDF;
	border-bottom:8px solid #29527B;
	border-left:1px solid #29527B;
	border-right:1px solid #29527B;
	color:#29527B;
	font-family:Arial, Helvetica, sans-serif;
	font-size:12px;
	text-align:left;
	padding-left:2px;
	width:173px;
}

173 + 2= 175 (desired width of navbox)

Stu
Stu's picture
Offline
Enthusiast
Bristol uk
Last seen: 16 years 35 weeks ago
Bristol uk
Joined: 2004-01-20
Posts: 282
Points: 0

Lessen Width to make up for padding or margin?

Yep.

In standards compliant mode the total width of the box is
width+padding+border.

However IE in quirks mode has a faulty box model where the width INCLUDES the padding and border. IE6 can be switched into standards compliant mode with the correct doctype, but any IE pre IE6 needs hacks to correct.

It's not what you do it's the way that you do it.
So do it with STYLE
http://www.s7u.co.uk

mattgloss
Offline
newbie
Glasgow Scotand
Last seen: 16 years 23 weeks ago
Glasgow Scotand
Joined: 2004-04-14
Posts: 9
Points: 0

Lessen Width to make up for padding or margin?

could you tell us the correct doctype, I have the same problem and have been getting around it like this... which is a bit ugly!

<html>
<head>
<style type="text/css">
<!--
#padding {
	background-color: #0000FF;
	padding: 12px;
}
#content {
	width:100px}
-->
</style>
</head>

<body>
<div id="content">
	<div id="padding">
	Content width 100px
	</div>
</div>

</body>
</html>

Stu
Stu's picture
Offline
Enthusiast
Bristol uk
Last seen: 16 years 35 weeks ago
Bristol uk
Joined: 2004-01-20
Posts: 282
Points: 0

Lessen Width to make up for padding or margin?

It's not what you do it's the way that you do it.
So do it with STYLE
http://www.s7u.co.uk