我已經使用了搜索功能,它不會center
,因爲我無法理解一些建議,而那些我無法工作。谷歌也沒有給我任何結果。不能將div放在另一個div內
我想用1個div作爲'背景',這樣屏幕下的第一個150px
就是藍色的。
然後我想要centered
框中的徽標950px
寬由150px
下來。
「logo div」(我稱之爲headercontent
)需要位於headerbackgroundblue
div的頂部,這是我管理的。
但是它不會居中該專區內(950px
寬心將存儲的所有內容,以便它看起來在所有屏幕好箱子,但藍色是1920px
寬,使網站更好看在更大的分辨率。
CSS
body {
padding: 0;
margin: 0;
}
.headercontent {
z-index: 2;
position: absolute;
height: 150px;
width: 950px;
margin-right: auto;
margin-left: auto;
}
.bluebackgroundtop {
height: 150px;
width: 1920px;
margin-right: auto;
margin-left: auto;
background-color: #3c56a6;
z-index: 1;
position: absolute;
}
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Kleenzone - Commercial Cleaning Services</title>
<link href="style/style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="bluebackgroundtop"></div>
<div class="headercontent">
<H1> KLEENZONE </H1>
</div>
</body>
</html>
請提供的HTML代碼,太。 – KittMedia
提供HTML代碼。 – SN1Dan
normaly你會做這樣的事情:http://jsfiddle.net/NicoO/42A8M/ –