html - 到达 div 末尾时是否可以设置“border-radius”?
问题描述
解决方案
您可以通过将顶部间距设置为父级并将底部间距设置为子级来实现。
- 使父级可滚动
- 隐藏父滚动条(因为滚动条在视觉上接触到窗口底部边缘)
- 为子元素添加一个margin-bottom
* {margin: 0;box-sizing: border-box;}
body {
background: #0fb;
}
.Popup {
position: fixed;
width: 70vw;
top: 15vh;
left: 15vw;
bottom: 0vh; /* has to be at 0! */
overflow-x: hidden;
overflow-y: auto;
scrollbar-width: none; /* FF https://stackoverflow.com/a/49278385/383904 */
-ms-overflow-style: none; /* IE 10+ */
}
.Popup::-webkit-scrollbar { /* WebKit */
width: 0;
height: 0;
}
.Popup-content {
padding: 20px;
height: 150vh; /* Demo only... you place text inside */
margin-bottom: 15vh;
border: 10px dashed #000;
background: #0bf;
}
<h2>Lorem Ipsum</h2>
<div class="Popup">
<div class="Popup-content">
Scroll...
</div>
</div>
如果不隐藏滚动条,我认为在纯 CSS 中没有任何明智的解决方案,而不是不使用一些 JavaScript。
推荐阅读
- angular - Nginx 角码头工人
- weld - 焊缝 junit5 与焊缝 3
- python - 为什么我不能使用 Django 服务器进行生产?
- ruby - 搜索/解析 XML 并排除某些节点而不删除它们?
- c# - 如何合并具有相同数据的两行?
- javascript - 简单 JS 滑块上的递归过多
- javascript - 如何在 AJAX 函数中进行 Strtotime?和错误时刻
- apache-kafka - Kafka Zookeeper 身份验证不起作用
- c# - 如果 List<> 的类归档,它在 db 中的外观如何?
- jmeter - JMeter: Is it possible to add HTTP Request sampler during run?