css - Bootstrap 4 在 div 上使用粘性和浮动
问题描述
我正在使用带有float-left
和float-right
类的 Bootstrap 4,这些类可以使我的 2 个 div 彼此保持左右并且效果很好,但是我希望正确的 divsticky
也是如此,但这似乎不起作用。我position-sticky
在 div 上使用float-right
浮动类参考此处: 浮动 URL
粘性类参考:位置 URL
基本上我的 HTML 看起来像这样:
<section class="section">
<div class="float-left col-md-8">
<div class="row sameheight-container">
<div class="col-md-12">
@*Form fields, such as input, select etc.*@
</div>
</div>
</div>
<div class="float-right col-md-4 position-sticky">
<div class="row sameheight-container">
<div class="col-md-12">
<div class="card card-block sameheight-item">
<table>
<thead>
<tr>
<th>Quantity</th>
<th>Price</th>
<th>Total</th>
</tr>
</thead>
<tbody>
<tr>
<td>2</td>
<td>3</td>
<td>6</td>
</tr>
<tr>
<td>5</td>
<td>10</td>
<td>50</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
请注意,第一个 Div 有一堆表单控件,所以我已将其删除并在其中添加评论。
有没有办法做到这一点?
谢谢你的帮助!
解决方案
推荐阅读
- c++ - SDL2 加载带有特殊字符的文件
- c# - iTexsharp pdf中表格单元格的不同单元格事件
- android - 为 AndroidViewModel 创建 ViewModelFactory 的正确方法是什么
- java - JUnit 测试 - 如何检查扫描仪的各种输入不匹配
- sql - SQL Server:如何更改 sa 的密码?
- php - MVC 模式:如果模型需要调用其视图的函数,如何解决这个问题?
- amazon-s3 - spark.read.parquet 在 Colab 中不起作用
- javascript - 正则表达式:匹配所有字符串,但捕获两个符号之间的组
- javascript - req.user 是未定义的节点 + 快递 + 护照 + 猫鼬
- c++ - 对象单击场景时如何找出对象接口类指针?