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 div
s with a blackboard style.
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?
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.
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">
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 */
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.
精彩评论