html - 右侧的引导列表组项放置按钮
问题描述
如何将按钮放置在靠近元素的右侧?(对齐到名称级别)
html
<div class='list-group-item flex-column disabled'>
<span class='circle'></span>
<p class='name'>Name</p>
<button id="test" type="button">Reject</button>
</div>
css
.circle {
display: table-cell;
border-radius: 50%;
width: 50px;
height: 50px;
background: #c7c7c7;
}
#test {
float:right;
}
.name {
display: table-cell;
vertical-align: middle;
padding-left: 5px;
}
我想要这个: Jsfiddle
解决方案
您可以使用Bootstrap 4 中包含的Flex Utility 类。
.d-flex
将和添加.align-items-center
到容器中。
最后,默认p
有一个margin-bottom
。删除它以确保它垂直居中。更新左右边距以添加间距。
.circle {
display: block;
border-radius: 50%;
width: 50px;
height: 50px;
background: #c7c7c7;
}
.name {
margin: 0 5px;
}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css" integrity="sha384-9gVQ4dYFwwWSjIDZnLEWnxCjeSWFphJiwGPXr1jddIhOegiu1FwO5qRGvFXOdJZ4" crossorigin="anonymous">
<div class='list-group-item d-flex align-items-center disabled'>
<span class='circle'></span>
<p class='name'>Name</p>
<button id="test" type="button">Reject</button>
</div>
推荐阅读
- c# - C# 覆盖实体框架 Database.ExecuteSqlCommand
- select - 使用 DataTables 在选择中插入复选框时出现问题
- git - 在 Powershell 中返回 Git 提交 ID
- python - Django 显示链接到登录的特定用户的帖子
- python - 从具有不同环境的另一个脚本运行具有自己环境的脚本(Windows 10)
- c# - C# Windows 窗体如何获取 ListView 项
- uber-api - Uber Eats API 范围
- swift - 如何在 Swift 中约束它位于其之上的项目
- kubernetes - 注解 cert-manager.io/cluster-issuer: acme-issuer 是否足以生成 TLS 证书?
- sql-server - SQL Server 多用户