【发布时间】:2011-08-29 19:36:17
【问题描述】:
我正在尝试使用固定的标题和侧边栏创建布局,但我不想在浏览器的中心进行布局。显然这是一个问题,因为固定通常不允许这样做。我考虑过在所有内容周围放置一个包装器并使用 margin: 0px auto;等等,但那没有用,有可能吗?
#header {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 150px;
background-color: #FFF;
z-index: 100;
}
#content {
width: 1112px;
overflow: auto;
padding-top: 150px;
}
#sidebar {
position: fixed;
top: 0;
left: 0;
width: 275px;
height: 100%;
z-index: 100;
}
想过这样的事情,但没有用:
body {
margin:0px 0px; padding:0px;
text-align:center;
}
#wrapper {
text-align: left;
margin: 0px auto;
}
div:
<div id="wrapper">
<div id="header"></div>
<div id="content"></div>
<div id="sidebar"></div>
</div>
【问题讨论】:
-
您能否详细说明您想要什么。您想要将标题和侧边栏固定在左侧并且内容居中吗?
-
@Amy 你在 ie6 上遇到这个问题了吗
标签: css width position center fixed