我想正確定位一些元素,但他們似乎剪輯/互相干擾,我不知道如何解決這個問題。CSS元素和定位
我想要一個固定位置的標頭頂部&底部有一箇中心元素,不會與他們剪輯。在中心內部,我想要一個左側和右側邊欄,它也不會夾在中間。
定位&大小不應該是絕對的。
頂部/底部作爲頁眉/頁腳只有這些應該是固定的。
隨着我的意思是,如果我改變我的瀏覽器的寬度。例如內容應「調整」
任何想法或暗示就如何實現這一目標?
|--------------------------------|
| Top (fixed header) |
|--------------------------------|
|------| Center/content |------|
|------| |------|
|------| ^ |------|
|------| | |------|
| Left | <--stretch--> | Right|
|------| | |------|
|------| v |------|
|------| |------|
|--------------------------------|
| Bottom(fixed footer) |
|--------------------------------|
這是我現在有,頁眉頁腳&被corretly的位置,但他們交鋒與我的其他元素...
html,
body {
height: 100%;
margin: 0 auto;
}
body {
color: #fff;
font-family: Verdana, Geneva, sans-serif;
text-shadow: 1px 1px black;
}
.page {
position: relative;
width: 100%;
height: 100%;
background: #fff;
}
.header {
position: fixed;
width: 100%;
top: 0;
background: #ddd;
}
.footer {
position: fixed;
float: bottom;
bottom: 0;
background: #aaa;
}
.left {
width: 20%;
height: 100;
float: left;
background: #ccc;
}
.middle {
width: 60%;
float: left;
display: block;
background: #ddd;
}
.right {
width: 20%;
float: right;
background: #bbb;
}
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="css/style.css">
<title>Titel</title>
</head>
<body>
<div class="page">
<div class="header">
<p>test2</p>
</div>
<div class="center">
<div class="left">
<p>test2</p>
</div>
<p>test2</p>
<div class="right">
<p>test2</p>
</div>
</div>
<div class="footer">
<p>test</p>
</div>
</page>
</body>
</html>
你能告訴我們你的html嗎? –
如果你已經在使用'position:fixed',你爲什麼要特別想要「定位和大小不應該是絕對的」 –
編輯我的文章是更多的指定@WilliamIsted並添加我的HTML – Dinh