Jump to content

Recommended Posts

Your table is making the main div wider.

 

Total width is  margin + border + padding + width

 

So your table should be about 888px wide and have a padding of 12px for a div 900px width. or have table that's 900px with no padding.

 

How are you giving your table padding?

 

 

Here is my CSS:

 


div.header {
width:900px;
background-color:#363E44;
padding:12px;
font-family:Arial, Helvetica, sans-serif;
font-size:13px;
color:#FFFFFF;
font-weight:bold;
}

table.data {
width:900px;
padding:12px;
border-collapse:collapse;
}

table.data th {
background-color:#EEEEEE;
padding:12px;
font-family:Arial, Helvetica, sans-serif;
font-size:11px;
font-weight:bold;
color:#000000;
}

table.data td {
background-color:#FFFFFF;
padding:12px;
font-family:Arial, Helvetica, sans-serif;
font-size:11px;
color:#000000
}

I did the math wrong

 

Total width is  margin + border + padding + width + padding + border + margin

 

So your table is 0 + 0 + 12 + 900 + 12 + 0 + 0 pixals wide for a total of 924pxs wide and it's forcing your 900px div to be 24pxs to wide 

 

The table is not inside the div.  The div is above it.  They are completely separate elements.

Sorry I read that but forgot about it when I was pondering the problem.

 

I would think they should be the same width, 924pixals.

 

Do you have firefire foxes firebug or can you use chrome to see if something else is a problem?

The table has nothing to do with it. The box model says the total width of a box object is the width + right padding + left padding + right border + left border + right margin + left margin.

To see it in your example kill the table and add a second div. Just duplicate the css for the second one, but make back ground color different and remove the padding.

 

<style type="text/css">

div.header {
width:900px;
background-color:#363E44;
padding:12px;
font-family:Arial, Helvetica, sans-serif;
font-size:13px;
color:#FFFFFF;
font-weight:bold;
}
div.foot {
width:900px;
background-color:pink;
//padding:12px;
font-family:Arial, Helvetica, sans-serif;
font-size:13px;
color:#FFFFFF;
font-weight:bold;
}

</style>
</head>
<body>
<div class="header">
some thing here
</div>

<div class="foot">
some thing there
</div>

</body>
</html>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.