我想正确定位一些元素,但他们似乎剪辑/互相干扰,我不知道如何解决这个问题。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