Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

CSS Forum


You are currently viewing our CSS Forum as a guest. Please register to participate.
Login



Reply
Why does padding add to my box height?
Old 05-25-2007, 11:12 PM Why does padding add to my box height?
Noobstein's Avatar
Super Talker

Posts: 102
Name: Kyle Shwartz
Trades: 0
I set the height dimensions of the div. Then when I added some padding, it changed the height. I thought it was just going to move everything inside the box 5 px away from the borders. It did that, but it also expanded the ******n box!

Quote:
.content
{
height: 304px;
background: #F7EFC9 url(images/bulbback4.jpg);
background-position: right top;
background-repeat: no-repeat;
border-width: 10px;
border-style: solid;
border-color: #F4E598;
text-align:left;
font-family: Tahoma, Arial;

scrollbar-3dlight-color:blue;
scrollbar-arrow-color:black;
scrollbar-track-color:#F4E598;
scrollbar-darkshadow-color:;
scrollbar-face-color:#F7EFC9;
scrollbar-highlight-color:white;
scrollbar-shadow-color:black;

position: static;
overflow: auto;
padding: 5px;
}
Noobstein is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 05-26-2007, 12:02 PM Re: Why does padding add to my box height?
LadynRed's Avatar
Defies a Status

Posts: 10,016
Location: Tennessee
Trades: 0
I'm assuming you're seeing this behavior in IE ??
It is because of IE's broken box model.
An article about this box model problem:
http://www.communitymx.com/content/a...989953B6F20B41


Quote:
According to the W3C specs, the width of the white content area between the grey padding zones is 100px. The padding, borders and margins are added on to the outside of the "width", to arrive at a total of 130px for the visible bordered box dimension, or 150px from outer (purple) margin edge to outer margin edge.
__________________
Web Goddess & Web Standards Evangelist :) - Tables Be Gone !!

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE


Last edited by LadynRed; 05-26-2007 at 12:04 PM..
LadynRed is offline
Reply With Quote
View Public Profile
 
Old 05-26-2007, 08:03 PM Re: Why does padding add to my box height?
Noobstein's Avatar
Super Talker

Posts: 102
Name: Kyle Shwartz
Trades: 0
Problem is with both browsers actually LadynRed,

It sticks out more with firefox because I've wrapped the div (with the padding) in another div, and in IE6 the outer div automatically expands with it, whereas in firefox, the inner div overlaps the outer div.

me not understand
Noobstein is offline
Reply With Quote
View Public Profile
 
Old 05-26-2007, 10:58 PM Re: Why does padding add to my box height?
taketherisk's Avatar
Skilled Talker

Posts: 89
Name: Brett
Location: New Zealand
Trades: 0
Try this code:

Tell me how you go with it.

Code:
<html>
<head>
<title>Untitled</title>
<style type="text/css">
<!--
.content {
  height: 304px;
  background: #F7EFC9 url(images/bulbback4.jpg);
  background-position: right top;
  background-repeat: no-repeat;
  border-width: 10px;
  border-style: solid;
  border-color: #F4E598;
  text-align:left;
  font-family: Tahoma, Arial;

  scrollbar-3dlight-color:blue;
  scrollbar-arrow-color:black;
  scrollbar-track-color:#F4E598;
  scrollbar-darkshadow-color:;
  scrollbar-face-color:#F7EFC9;
  scrollbar-highlight-color:white;
  scrollbar-shadow-color:black;

  position: static;
  overflow: auto;
}
.innercontent {
   padding: 5px; 
}
-->
</style>

</head>
<body>

<div class="content"><div class="innercontent">

Hello i have 5px padding and a height of 304px

</div></div>

</body>
</html>
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE
taketherisk is offline
Reply With Quote
View Public Profile
 
Old 05-26-2007, 11:17 PM Re: Why does padding add to my box height?
Noobstein's Avatar
Super Talker

Posts: 102
Name: Kyle Shwartz
Trades: 0
^that was a good test to see if it would again expand the box, and it didn't. thank you. It's certainly a legitimate work around if I weren't obsessed with finding out why this happens.

My question about why the text padding expands the entire div remains unanswered. Any clues as to why this happens when my height is clearly set?

Can I surmise that the padding property overides the height property?

Last edited by Noobstein; 05-26-2007 at 11:20 PM..
Noobstein is offline
Reply With Quote
View Public Profile
 
Old 05-26-2007, 11:29 PM Re: Why does padding add to my box height?
taketherisk's Avatar
Skilled Talker

Posts: 89
Name: Brett
Location: New Zealand
Trades: 0
Quote:
Can I surmise that the padding property overides the height property?
Not quite. The padding property adds onto the height property in Internet Explorer. The code i gave you is cross browser.

Firefox does not add padding to the height, but because you gave the outside div some padding, that will make it the inside div height + the padding of the outside one = The height of the outside div.

__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE
taketherisk is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Why does padding add to my box height?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.23103 seconds with 12 queries