css - 努力在 CSS 中正确溢出
问题描述
出于某种原因,我陷入了这个相当简单的问题。我想要一个可滚动的“网站”(只是一个 looong jpg 截图),通过 iPad 作为我作品集的一部分。目标是在不占用页面大量空间的情况下完整展示访问网站的体验。
出于某种原因,我无法让溢出正常工作。从表面上看,这似乎不是一个难题,但它让我很难过。任何朝着正确方向轻推都会受到赞赏。
.nest {
position: relative;
height: 712px;
overflow-y: scroll;
}
.ipad {
position: absolute;
top:0px;
right:0;
bottom:auto;
left:0;
}
.container{
height: 940px;
width: 712px;
position: absolute;
top:45px;
background: red;
}
.content {
width: 712px;
overflow: auto;
}
<div class="nest">
<div class="container">
<img class="content" src="https://i.ibb.co/bWmxzkv/Screenshot-2021-05-05-AAA-Service-Company-Demolition-Contractors.png">
</div>
<img class="ipad" src="https://i.ibb.co/kcRh56j/ipad-frame-copy.png">
</div>
解决方案
overflow-y: scroll;
从类中删除.nest
,并将其添加到.container
类中。
.nest {
position: relative;
height: 712px;
}
.ipad {
position: absolute;
top: 0px;
right: 0;
bottom: auto;
left: 0;
}
.container {
height: 940px;
width: 712px;
position: absolute;
top: 45px;
background: red;
overflow-y: scroll;
}
.content {
width: 712px;
overflow: auto;
}
<div class="nest">
<div class="container">
<img class="content" src="https://i.ibb.co/bWmxzkv/Screenshot-2021-05-05-AAA-Service-Company-Demolition-Contractors.png">
</div>
<img class="ipad" src="https://i.ibb.co/kcRh56j/ipad-frame-copy.png">
</div>
推荐阅读
- security - 如何允许通过 ssh 仅复制给定文件?
- selenium-webdriver - 将鼠标悬停在菜单上并单击带有 selenium vba 的子菜单项
- regex - grep 可以删除上下文,但不能删除整行?
- c++ - 使用 C++20 fmt 限制结果的总大小
- c# - 从对象中查找不同并删除重复项
- jquery - 从嵌套的对象数组中获取数据
- c++ - 将 Integer 转换为 4 字节 ungisned char 向量(以 Big endian 字节顺序)
- c++ - ifstream 没有读取任何内容
- c# - WPF子控件继承
- java - 如何更改slf4j logger的日志文件名