我有一個div容器包含2個div:橫幅和內容。橫幅和內容的CSS屬性寬度都設置爲100%,但渲染時不同。css divs有不同的寬度,當他們不應該
這是我的index.html
<!doctype html>
<html lang="en">
<meta charset="UTF-8">
<link href="style.css" rel="stylesheet"/>
<title>JoeY34kaze's gw2 stuff</title>
<body>
<div id="container">
<header>
<h1>
This is my header.
</h1>
</header>
<div id="banner">
<h2>
This is the banner.
</h2>
</div>
<div id="content">
<p>Content goes here.</p>
<p>Content goes here.</p>
<p>Content goes here.</p>
<p>Content goes here.</p>
<p>Content goes here.</p>
<p>Content goes here.</p>
<p>Content goes here.</p>
<p>Content goes here.</p>
<p>Content goes here.</p>
<p>Content goes here.</p>
<p>Content goes here.</p>
<p>Content goes here.</p>
<p>Content goes here.</p>
<p>Content goes here.</p>
<p>Content goes here.</p>
<p>Content goes here.</p>
<p>Content goes here.</p>
<p>Content goes here.</p>
<p>Content goes here.</p>
</div>
</div>
</body>
</html>
這是我的style.css
body {
text-align:center;
}
header {
width:100%;
height:100px;
background: #dbdbdb;
z-index:10;
position: fixed;
}
#container {
overflow:hidden;
min-width:100%;
padding:0;
}
#banner {
width:100%;
height: 500px;
padding:0;
position: fixed;
top: 100px;
background-color:#707070;
}
#content {
height:100%;
width:100%;
position: relative;
top:400px;
background-color: #ebebeb;
}
和網頁看起來是這樣的:
,直到我解決這個問題頁面也在這裏住https://gw2stuff.herokuapp.com/
的問題是,在右側的2周的div沒有對齊,但他們應該。 我認爲問題來自內容div的相對位置,但我無法修復它,所以我的問題是我如何對齊2個div,使它們的寬度匹配?
這是你的解決方案,Paulie打敗了我:-) – Michiel