【发布时间】:2019-09-02 07:02:47
【问题描述】:
所以,我试图找出一种很酷/不同的方式来展示与长静态图像不同的完整网页设计。我的目标是有一个“监视器”图形棒,而当用户滚动时,图像(完整的网页)在其中流动。我通过在其下方流动图像的位置粘性“监视器”图形来解决它。我喜欢它如何滚动内容,然后在完成后将部分向上推。
问题在于图像溢出。我能够用边框隐藏顶部的溢出(我认为从长远来看会很好)..但我不知道如何隐藏底部的溢出并仍然保持相同的滚动行为现在有。
如果能以某种方式摆脱“监视器”底部的空间,让它正好位于容器的底部,那就太好了。我想这个功能最终会像一个粘性 iframe,可以在框架本身之外滚动,然后在内容到达结尾后向上推。
我能做到这一点,但在保持滚动行为的同时隐藏 div 底部的溢出确实存在问题。
示例 >> https://codepen.io/cjcort/pen/NWKryVa
提前致谢!
<style>
body {
margin:0px;
}
.container-1 {
background-color:grey;
}
.container-2 {
background-color:lightblue;
}
.parent {
width:50%;
margin:0px auto;
padding:100px 0px;
}
.sticky-monitor {
text-align: center;
z-index:1
}
.grey {
border-top:70px grey solid;
}
.blue{
border-top:70px lightblue solid;
}
.sticky-monitor img {
width:100%;
left:0;
right:0;
margin-left:auto;
margin-right:auto;
z-index:4
}
.image {
margin-top:-65%;
text-align:center;
}
.image img {
width:93%;
height:1000px !important;
margin:auto
}
.is-sticky {
position: sticky;
position: -webkit-sticky;
position: -moz-sticky;
position: -ms-sticky;
position: -o-sticky;
top: 0;
}
</style>
<div class="container-1">
<div class="parent">
<div class="sticky-monitor is-sticky grey">
<img src="https://charliecort.com/test/computer.svg">
</div>
<div class="image">
<img src="https://images.unsplash.com/photo-1563468415006-0b70ca8eb306?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=934&q=80" />
</div>
</div>
</div>
<div class="container-1">
<div class="parent">
<div class="sticky-monitor is-sticky grey">
<img src="https://charliecort.com/test/computer.svg">
</div>
<div class="image">
<img src="https://images.unsplash.com/photo-1563468415006-0b70ca8eb306?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=934&q=80" />
</div>
</div>
</div>
【问题讨论】: