html - 防止多个固定定位元素重叠
问题描述
如果我的页面上有两个 div。一个在页面顶部style="position:fixed; left:0; top:0;right:0;"
有固定定位,一个在页面左侧有固定定位style="position:fixed; left:0; top:0;bottom:0;"
有没有办法让左侧 div 定位,使其顶部边缘与顶部定位 div 的底部边缘对齐,没有硬编码边距或填充?默认情况下会有一些部分重叠
解决方案
试试这个,我想你也想做同样的事情。
.parent{
position: relative;
background-color: #000;
width: 600px;
height: 400px;
}
.child1,.child2{
position: absolute;
left: 0;
background-color: #f00;
height: 190px;
}
.child1{
top: 0;
right: 0;
}
.child2{
bottom: 0;
width: 200px;
}
<div class="parent">
<div class="child1"></div>
<div class="child2"></div>
</div>
推荐阅读
- reactjs - 如何在 React-Native Webview 中运行 React JS 构建?
- android - 如何在 Android 设备处于锁定模式时接收/发送广播
- python - Pyqgis:编写自动化单元测试
- java - Android - 将日期转换为时间戳
- java - 安全地投射到
- github - github:“更新被拒绝,因为您当前分支的尖端落后”我该如何解决?
- apache-spark - Zeppelin Notebook 上默认用户创建 Spark 池
- c# - Elasticsearch.Net.UnexpectedElasticsearchClientException:在从 ES 获取数据期间
- java - 有没有办法在 JPA 存储库的 @Query 注释中使用常量(EnumType Ordinal)值?
- c# - 此请求无权执行此操作。Azure blobClient