我想在页面底部放置一个div,并将其宽度设置为960px,在页面中央,到左边框的最小距离为170px。这是我的代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
</head>
<style type="text/css">
body{width:100%;height:100%;}
*{padding:0;margin:0;}
#wrap{position:fixed;margin:0 auto;margin-left:170px;width:960px;overflow:auto;bottom:0;height:100px;}
</style>
<body>
<div id="wrap">
test test test test test test test test test test test test test test test test test test test test test test test test
</div>
</body>
</html>
但是当屏幕宽度为1024时,div#wrap
没有滚动,右侧部分不显示。我该如何解决?
最佳答案
我想我理解了这个问题,但我仍然不清楚您要构建什么。
你应该改变
position : fixed;
到:
position : absolute;
这解决了您的滚动问题。
. . .
*注意:我也认为你可以删除
overflow: auto;
此外,更改:
body{ width:100%;height:100%; }
到:
html, body{
width:100%;
min-height: 100%;
height: auto !important;
height:100%;
}
关于CSS 位置 :fixed overflow:auto,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4679864/