我试图将一个容器 div 放在我的背景上,我通常对此完全没有问题。我通常只添加css“margin:0 auto;”。对于这个网站,我不知道为什么,它可能是 MIME 类型或 CSS3 或其他东西......但 div 不会居中。
这是我的HTML...
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HEAD>
<TITLE>title</TITLE>
<link rel="stylesheet" type="text/css" href="style.css" />
<BODY>
<div class="container">
</div>
</BODY>
</HTML>
这是我的 CSS ......
body {
background-image: linear-gradient(left top, #000000 30%, #0000FF 90%);
background-image: -o-linear-gradient(left top, #000000 30%, #0000FF 90%);
background-image: -moz-linear-gradient(left top, #000000 30%, #0000FF 90%);
background-image: -webkit-linear-gradient(left top, #000000 30%, #0000FF 90%);
background-image: -ms-linear-gradient(left top, #000000 30%, #0000FF 90%);
background-image: -webkit-gradient(linear, left top, right bottom, color-stop (0.3, #000000), color-stop(0.9, #0000FF));
height: 100%;
width: 100%;
margin: 0;
width: 0;
}
.container
{
margin-left: auto;
margin-right: auto;
position: relative;
width: 940px;
z-index: 0;
width: 940px;
top: -10px;
height: 80%;
background-color: #F0F8FF;
border-radius: 0px 0px 35px 35px;
-moz-border-radius: 0px 0px 35px 35px;
-webkit-border-radius: 0px 0px 35px 35px;
border: 10px solid #696969;
}
请忽略我的 CSS 上糟糕的格式。这不是它在文件中的方式,这只是复制它的错误。我最初测试的浏览器也是 Chrome。