【发布时间】:2018-11-05 16:19:24
【问题描述】:
我正在尝试修复页脚,同时仍然在上面的 div 上使用剪辑路径。我希望页脚越往下滚动,在中间 div 下方越明显。
我尝试在位置设置为固定时做底部:0 和其他各种浮动。当位置未定义或设置为相对位置时,页脚将像往常一样放在页面底部。
Codepen:https://codepen.io/Torsken/pen/OZKWvJ
这是我到目前为止的代码;
<body>
<div class="background_top">
<a href="#"></a>
</div>
<div class="background_middle_1">
<a href="#"></a>
</div>
<div class="background_middle_2">
<a href="#"></a>
</div>
</body>
<footer>
<div class="footer">
<a href="#"></a>
</div>
</footer>
.background_top {
background-color: #232323;
height: 70vh;
width: 100vw;
-webkit-clip-path: polygon(0 0, 100% 0, 100% 40%, 0 100%);
clip-path: polygon(0 0, 100% 0, 100% 96%, 0 100%);
z-index: -200;
}
.background_middle_1 {
background-color: green;
height: 60vh;
width: 100vw;
-webkit-clip-path: polygon(0 0, 80% , 100% 80%, 0 100%);
clip-path: polygon(0 0, 100% 0, 100% 96%, 0 100%);
z-index: -220;
margin-top: -45vh;
}
.background_middle_2 {
background-color: green;
height: 80vh;
width: 100vw;
-webkit-clip-path: polygon(0 0, 100% 0, 100% 100%, 0 70%);
clip-path: polygon(0 0, 100% 0, 100% 96%, 0 100%);
z-index: -220;
}
footer {
margin: 0;
bottom: 0;
padding: 0;
z-index: -230;
}
.footer {
background-color: blue;
height: 50vh;
position: fixed;
}
【问题讨论】: