CSS 位置 :fixed overflow:auto

标签 css overflow

我想在页面底部放置一个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&nbsp;test&nbsp;test&nbsp;test&nbsp;test&nbsp;test&nbsp;test&nbsp;test&nbsp;test&nbsp;test&nbsp;test&nbsp;test&nbsp;test&nbsp;test&nbsp;test&nbsp;test&nbsp;test&nbsp;test&nbsp;test&nbsp;test&nbsp;test&nbsp;test&nbsp;test&nbsp;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/

相关文章:

html - 将 CSS 网格与转换结合

c# - 在 asp.net mvc (razor) 中重用组件作为自定义文本字段、跨度等

javascript - 如何等待用javascript加载的图像?

css - 溢出滚动不适用于绝对定位的元素

c++ - c++中如何避免内存溢出引起的错误信息

python - 如何将此 Python 代码转换为 C++

jquery - css 适用于除 IE 以外的所有其他浏览器

html - 如何为元素或 div 的内容设置样式?

twitter-bootstrap - 如何在 Bootstrap 列中使用文本溢出?

css - 滑动选项卡的背景在滚动/溢出部分消失