[英]IE has different height/width for div than Firefox
IE中的div
高度和寬度都有問題。
在我的網頁上, http://www.ricominciodame.it/eventi.php ,有一些黑板風格的div
。
在Firefox中,它們都可以正常工作,但在IE(7和8)中,寬度較低,背景也會減少。
以下是我的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;
}
我該如何解決這個問題?
您的網頁在IE中運行的怪癖模式所造成的DOCTYPE
。 您必須使用http://www.w3.org/QA/2002/04/valid-dtd-list.html中的任何一個
此外,最好從w3驗證器驗證您的網站。
您的doctype是否設置為將瀏覽器置於標准模式? 例如:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
在設計新頁面之前,我總是'重置'css。 我加載我的CSS文件(注意我首先加載重置,然后是實際的布局):
<link rel="stylesheet" href="css-styles/reset.css" />
<link rel="stylesheet" href="css-styles/all.css" />
我的重置CSS看起來像這樣:
/* 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 */
可能是一個箱型問題: http : //css-tricks.com/the-css-box-model/
我會做這樣的事情:
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;
}
在IE中,填充在你聲明的260px寬度的每一邊占用20px。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.