当内容延伸到页面下方时,HTML 正文不会滚动

标签 html css scroll

由于某种原因,即使我的内容延伸到页面下方并溢出 CSS,我也无法向下滚动页面。出现滚动条,但无法向下滚动。如果您需要的页面代码多于我提供的代码,请告诉我!

窗口下方延伸内容的 HTML:

<div id="images">
<p>Here you will find some of my Photoshops!</p>
<img style = "top:50%;left:50%;margin-left:-350px;" src="lufthansa747-8.jpg" width="720" height="460">
<img style = "top:100%;left:50%;margin-left:-350px;" src="advert.jpg" width="720" height="460">

可能影响该区域的区域代码的CSS:

#images p{
position: fixed;
top: 40%;
left: 50%;
margin-left: -125px;
color: #1D60E2;
text-align: center;
}
#images img{
position: fixed;
}
body {
background-color: #C2DFFF;
min-height: 200px;
overflow: scroll;
}

最佳答案

我认为这是因为您使用了position:fixed属性。如果你想滚动查看所有内容,我想你应该删除它或用绝对定位替换它。

#images p{
position: absolute;
top: 40%;
left: 50%;
margin-left: -125px;
color: #1D60E2;
text-align: center;
}
#images img{
position: absolute;
}
body {
background-color: #C2DFFF;
min-height: 200px;
overflow: scroll;
}

真正的问题是:您想要实现什么目标?因为在大多数情况下,您当前的 CSS 并不是解决方案:)

关于当内容延伸到页面下方时,HTML 正文不会滚动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22989448/

相关文章:

html - 视频无法在所有浏览器上播放 (FFMPEG)

html - CSS 不再链接到特定文件夹

html - 使用描述符水平内联图像

d3.js - 水平滚动的 C3/D3 条形图

javascript - Bootstrap 轮播类型错误 : e[g] is not a function

html - 如何创建具有 div 和不同列宽的表格?

html - :last-child property not applied to element

javascript - 用户滚动到特定div的底部时,标题应显示

javascript - jquery滚动效果处理方法(scrollpoints, horizo​​ntal scroll "hijack")

javascript - 如何仅对 IE 应用 css 样式