pAkY88
pAkY88

Reputation: 6294

IE has different height/width for div than Firefox

I'm having trouble with div height and width in IE.

On my web page, http://www.ricominciodame.it/eventi.php, there are some divs with a blackboard style.
In Firefox, they all work fine, but in IE (both 7 and 8) the width is lower and the background is cut.

The following is my CSS:

div.evento {
    background : white url("images/sfondo_evento.png") top no-repeat;
    width : 260px;
    height : 207px;
    margin:5px;
    margin-left:0px;
    margin-bottom : 20px;
    padding-left : 20px;
    padding-right : 20px;
    padding-top : 20px;
    padding-bottom : 20px;
    color : white;
}

How can I fix this problem?

Upvotes: 4

Views: 19322

Answers (4)

vinhboy
vinhboy

Reputation: 8982

might be a box-model problem: http://css-tricks.com/the-css-box-model/

I would do something like this:

div.evento {
    background : white url("images/sfondo_evento.png") top no-repeat;
    width : 300px;
    height : 207px;
    margin:5px;
    margin-left:0px;
    margin-bottom : 20px;
    color : white;
}
div.evento-inner {
    padding-left : 20px;
    padding-right : 20px;
    padding-top : 20px;
    padding-bottom : 20px;
}

in IE, the padding is taking up 20px on each sides of the 260px width you are declaring.

Upvotes: 0

Sotiris
Sotiris

Reputation: 40096

Your page is running in ie quirks mode caused by the DOCTYPE. You have to use any of these http://www.w3.org/QA/2002/04/valid-dtd-list.html

Also, it's good to validate always your web site, from w3 validator.

Upvotes: 7

SuperSpy
SuperSpy

Reputation: 1314

I always 'reset' css before designing a new page. I load my CSS files(notice that I first load the reset, after that the actual layout):

<link rel="stylesheet" href="css-styles/reset.css" />
<link rel="stylesheet" href="css-styles/all.css" />

My reset CSS looks like this:

/* CSS Document */

/* Clear all styles */
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, font, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
dl, dt, dd, ol, ul, li,
fieldset, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td {
    margin: 0;
    padding: 0;
    border: 0;
    outline: 0;
    font-weight: inherit;
    font-style: inherit;
    font-size: 100%;
    font-family: inherit;
    vertical-align: baseline;}

/* remember to define focus styles! */
:focus {
    outline: 0;}

body {
    line-height: 1;
    color: black;
    background: white;}

ol, ul {
    list-style: none;}

/* tables still need 'cellspacing="0"' in the markup */
table{
    border-collapse: separate;
    border-spacing: 0;}

caption, th, td {
    text-align: left;
    font-weight: normal;}

blockquote:before, blockquote:after,
q:before, q:after {
    content: "";}

blockquote, q {
    quotes: "" "";}
/*Ceal all styles END */

Upvotes: 0

Keltex
Keltex

Reputation: 26436

Is your doctype set to put the browser in standards mode? For example:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" 
"http://www.w3.org/TR/html4/strict.dtd">

Upvotes: 6

Related Questions