Div不以IE为中心

Der*_*rek 2 html css internet-explorer

我相信你之前已经听过了......虽然它在Chrome和Firefox中完美运行,但div并没有正确地在IE中居中.我已经研究过并尝试过使用text-align和auto margin的东西但是空洞了.我也尝试用另一个div或其他东西替换标签,但没有任何积极的结果.任何人都可以提供任何见解将不胜感激.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
.thumbnails {
    background-color:white;
    border: solid 1px #000099;
    height:120px;
    width: 640px;
    overflow-y:scroll;
    margin-bottom:20px;
    position:relative;
    padding-top: 10px;
}

#hugeimage {
    background-color:white;
    border-top: solid 1px #000099;  
    border-left: solid 1px #000099;
    border-right: solid 1px #000099;
    height:550px;
    width: 640px;
    display:table-cell; 
    vertical-align:middle;
}

#hugeimage a,
#hugeimage img {
    margin: 0px;
    padding: 0px;
    border: 0px;
}

#imageinfo {
    background-color:white;
    border-left: solid 1px #000099;
    border-right: solid 1px #000099;
    width: 640px;
}

body {
    background-color: #99ccff;
    text-color: #000099;
}

</style>
</head>
<body>
    <h3 align="center">Ship Detail</h3>
    <center>
        <div class="filedrop">
            <div id="hugeimage">
                <a href="#" target="_blank">
                    <img src="images/spin/wait30.gif" />
                </a>
            </div>
            <div id="imageinfo"></div>
            <div class="thumbnails"></div>
        </div>
    </center>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

我从div中删除了数据.这个简单的标记仍然有巨大的图像和imageinfo div在IE中左对齐但不在chrome/ff中.

小智 5

删除<center>标签和align="center",并<div id="content">在所有内容周围添加包装.然后添加这个CSS样式.

#content {
    width: 960px;
    margin: 0 auto;
}
Run Code Online (Sandbox Code Playgroud)

例:

<div id="content">
    <h3>Ship Detail</h3>
    <div class="filedrop">
        <div id="hugeimage">
            <a href="#" target="_blank">
                <img src="images/spin/wait30.gif" />
            </a>
        </div>
        <div id="imageinfo"></div>
        <div class="thumbnails"></div>
    </div>
</div>
Run Code Online (Sandbox Code Playgroud)