html - 清晰属性 CSS[style="clear:both;" ]
问题描述
<div style="position:sticky">
tto
</div>
<div style="float:left; padding-bottom: 3000px">
blah
</div>
使用上面的代码粘贴位置不起作用。我尝试将所有这些都保存在容器中,以某种方式使“位置:粘性”起作用。
<div class="container">
<div class="sticky">
tto
</div>
<div style="float:left; padding-bottom: 3000px">
blah
</div>
</div>
.container{
display: flex;
flex-direction: column;
}
.sticky{
position: sticky;
top: 0;
}
后来令我惊讶的是,我看到有人用这段代码修复了所有问题。
<div style="position:sticky;top:0">
tto
</div>
<div style="float:left; padding-bottom: 3000px">
blah
</div>
<div style="clear:both;"></div> //extra div needed
有人可以解释一下不同容器中的“clear:both”属性如何使其工作以及这里发生了什么。提前致谢。
解决方案
推荐阅读
- c# - IIS下远程调试ASP.Net Core 2.2 + .Net framework
- sql - VBA、Access 和 SQL 的新手。我如何编写一个 SQL 查询来搜索我的 AccessDB 中的一个表并在找到它时给我一个 True/False?
- ios - 如何从 PhotoLibrary 存储所选视频的位置
- plotly-python - 如何使用 plotly 定义子图的布局
- java - 选择在 iOS 中未显示的特定移动元素,然后对其执行点击操作
- swift - 当用户位置改变时调用 mapView(_:viewFor:)
- c++ - 在编译时将整数和分数部分宏组合成一个新宏或双精度
- windows - 如何获取目录中具有特定扩展名的所有文件?
- excel - 对多列中的数据进行排序
- sql-server - 带有百分位问题的 SQL 自定义排序顺序