html - 如何为文本静音类向右浮动/向右拉动
问题描述
我正在尝试使文本静音类正确浮动。
向右浮动,向右拉。不工作
<table class="table table-bordered">
<tbody>
<tr>
<th class="card-header" colspan="2"></th>
</tr>
<tr colspan="2">
<td style="display: flex;">
<strong>Username:</strong> A Comment
<small class="form-text text-muted">5 mins ago</small>
<br/>
</td>
</tr>
</tbody>
</table>
文本静音向右浮动或向右拉以获得更好的视图。
解决方案
实际上,您在父元素中使用display: flex并且float无法正常使用它。有 2 个选项可以解决您的问题。
没有 Flex 选项 1:
从父元素中删除display: flex并添加带有text-muted类的float-right类。
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<table class="table table-bordered">
<tbody>
<tr>
<th class="card-header" colspan="2"></th>
</tr>
<tr colspan="2">
<td>
<strong>Username:</strong> A Comment
<small class="form-text text-muted float-right">5 mins ago</small>
<br/>
</td>
</tr>
</tbody>
</table>
使用 Flex 选项 2:
使用display: flex和justify-content: space-between并更新次要 HTML 结构。
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<table class="table table-bordered">
<tbody>
<tr>
<th class="card-header" colspan="2"></th>
</tr>
<tr colspan="2">
<td class="d-flex justify-content-between">
<div>
<strong>Username:</strong> A Comment
</div>
<small class="form-text text-muted">5 mins ago</small>
</td>
</tr>
</tbody>
</table>
推荐阅读
- android - 在使用 FucedLocationProviderClient 之前连接 GoogleApiClient
- node.js - node.exe 以代码 134 Visual Studio 退出
- javascript - Openlayers Geojson axios API 获取数据
- php - 如果语句 Laravel 与 substr
- amazon-web-services - 无法将触发器添加到 AWS Lambda
- java - 将 Spring @Value 注入 Camel 单元测试
- gatling - Gatling:提取崩溃:解析json响应时输入预期错误结束
- c++ - 检查我们是否枚举了所有结构成员
- ansible - 如何在条件下将变量与具有字符串值的其他变量进行比较
- python - Python 字符串操作 - 拆分、切片、从 HEX 转换为 DEC