html - 引导中心和右对齐问题
问题描述
我试图在我的代码中有一个居中日期值和右对齐的编辑链接的行。我不确定这是否最好在一列 div 和 css 或两个 div 中实现(一个 = 11,其他 = 1),但我尝试了第二种方法,它不会在行内居中日期值。有更好的解决方案吗?
电流输出:
当前的html:
<div className="row">
<div className="col-md-10">
<p className="text-center"><b>12/25/18</b></p>
</div>
<div className="col-md-1">
<a href="/app/annotation/edit/id" className="annotation-kanban-card__head-edit-link"><span className="glyphicon glyphicon-pencil" aria-hidden="true"></span></a>
</div>
</div>
解决方案
我推荐这种方法:
<div className="row">
<div className="col-md-12 title-with-button">
<p className="text-center"><b>12/25/18</b></p>
<a href="/app/annotation/edit/id" className="annotation-kanban-card__head-edit-link"><span className="glyphicon glyphicon-pencil" aria-hidden="true"></span></a>
</div>
</div>
使用以下 CSS:
.title-with-button {
position: relative;
}
.title-with-button {
position: absolute;
top: 0;
right: 0;
}
用于此的 CSS 相当少,并且根据标题的长度应该可以响应式地工作。此外,它还删除了一些不必要的 div 标签,以获得更简洁的 HTML。
推荐阅读
- zeromq - 如何在 jzmq Java 绑定中为 ZeroMQ 创建轮询器?
- bukkit - 如何修复异常的插件类型?
- loops - 仅 AutoHotkey L Clcik 和循环 MouseMove
- firebase - 过滤 Firestore 数据以仅包含当前用户信息
- discord - 被标记的人获得新角色
- python - Python - 相同类型的数据,相同的代码,但不同的结果
- runtime-error - 安装了 dbt 并且工作正常,但是得到 db cmdlet,函数错误
- python - 在回调中更新 matplotlib 图
- python - 如何修复拒绝在框架中显示 url,因为它在 webkitgtk python 中将 x 框架选项设置为拒绝
- rust - 如何使用 println!() 打印命名参数的子项?