目前,我有下面的HTML代碼,你可以看到有沒有指定的文檔類型:添加DOCTYPE斷裂的背景圖像對齊
<html lang="en">
<head>
<title>Website</title>
<meta charset="utf-8" />
<link rel="stylesheet" type="text/css" href="css/main.css" />
<link rel="stylesheet" type="text/css" href="css/style.css" media="screen" />
<!--[if gt IE 7]>
<link rel="stylesheet" type="text/css" href="css/ie.css" media="screen" />
<![endif]-->
<script type="text/javascript" src="js/jquery-1.10.2.js"></script>
<script type="text/javascript" src="js/plugins.min.js"></script>
<link rel="icon" type="image/x-icon" href="img/favicon.ico" />
</head>
<body>
<div class="container">
<div id="searchbar">
<form action="#" method="POST">
<div class="input-append">
<input class="span2" id="appendedInputButton" type="text" />
<button class="btn" type="button">Go!</button>
</div>
</form>
</div>
</div>
</body>
</html>
混合使用以下的style.css文件:
@font-face{
font-family: Comfortaa;
src: url('Comfortaa.ttf');
}
body{
background-color: #77d5fb;
background-image: url('bottom_bg.jpg');
background-position: center bottom;
background-repeat: no-repeat;
font-family: Comfortaa;
}
#searchbar{
width:700px;
height:200px;
position:absolute;
left:50%;
top:50%;
margin:-100px 0 0 -350px;
}
有代碼顯示我的背景圖像很好,但是當我按照引導程序的要求添加<!DOCTYPE html>
時,我的背景圖像聲明似乎是「ignored」並且只顯示指定的背景色。
我已經做了一些測試,發現背景位置導致了問題。
隨着background-position: center bottom
圖像將不會出現,但background-image: center
將出現,它會出現,但居中在頁面的頂部,我需要它在底部。
我該如何下壓該背景圖片?
@Fags不要再使用'doctype'。那是個老派。使用HTML5文檔類型:'<!DOCTYPE html>'。 – hungerstar