views:

966

answers:

5

Hi, i got an issue on firefox, while all IE, Safari and chrome are working.

<div class="forDiv">ddd</div>
<table class="forTable"> .... </table>


.forDiv {
width:100%;
border:3px solid #236FBD;
background-color: #236FBD;
}

.forTable{
width:100%;
border:3px solid #236FBD;
background-color: #236FBD;
}

in firefox, the div is a bit smaller. how can i fix it?

+3  A: 
.forDiv {
width:100%;
border:3px solid #236FBD;
background-color: #236FBD;
-moz-box-sizing: border-box;
}

.forTable{
width:100%;
border:3px solid #236FBD;
background-color: #236FBD;
-moz-box-sizing: border-box;
}
scott
due.. thx for you quick reply... but it doesn`t work for me.. i am on firefox3.....
shrimpy
+2  A: 

It's an inconsistency in how different browsers treat the width attribute - whether they include the border/padding dimensions in the width, or whether they consider them additional.

You can use the -moz-box-sizing attribute set to "border-box" to tell Mozilla-based browsers to emulate how IE does it in quirks mode (see this page for details).

Amber
mm, nice to know.
meder
but didn`t work for me..why
shrimpy
+1  A: 

Most likely has something to do with the margins or padding set in neighboring or containing elements. Hard to tell without the full context but also try setting the margin and padding attributes for the div and table and see what happens.

Kyle Kochis
+1  A: 

Ok, this appears to be the classic IE box-model inconsistency (or shall I say, bug?)

The simplest way around it is to define your div (the one containing ddd) inside a container div like this:

<div id="container">
  <div class="forDiv">ddd</div>
</div>

And define the CSS properties as follows:

#container
{
  width:100%;
}

.forDiv
{
  border: 3px solid;
}

This should give you the same size in both IE and Gecko.

Crimson
Seems like a beginning case of divitis. Definitely not a good solution, but sometimes the only available choice.
Residuum
but doesn`t work for Firefox....sigh...
shrimpy
A: 

Try overflow:hidden; i also had same problem. then i got this

link

from that i got soln. to make div's overflow:hidden and it worked fine for me.

Radhi