html - Bootstrap 在一行中设置 4 个元素
问题描述
我想在底部的一行中设置链接,例如“Link 1 left bottom”、“Link 2 center bottom”、“Link 3 right bottom”,但“Link 2”不以 PC 和移动设备为中心。
HTML:
<div>
<a id="contact" href="/contact">Link 1</a>
<a id="link" href="/repo">Link 2</a>
<a id="api" href="/json">Link 3</a>
</div>
CSS:
#contact{
float: left;
font-size: 20px;
padding-top: 0.17em;
}
#api{
float: right;
font-size: 20px;
padding-top: 0.17em;
}
#link{
display: inline;
font-size: 30px;
padding-right: 2.5%;
}
现在的样子
解决方案
您可以在类中使用引导程序构建d-flex
并justify-content-between
轻松实现。
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-WskhaSGFgHYWDcbwN70/dfYBj47jz9qbsMId/iRN3ewGhXQFZCSftd1LZCfmhktB" crossorigin="anonymous">
<div class="d-flex justify-content-between">
<a id="contact" href="/contact">Link 1</a>
<a id="link" href="/repo">Link 2</a>
<a id="api" href="/json">Link 3</a>
</div>
推荐阅读
- c# - EF Core 实体未添加到数据库
- ios - 全新安装时启动呼叫事务总是失败,Callkit iOS
- arrays - 如何在 Swift 4 中将金字塔类型的字符串转换为双精度数组
- apache-spark - SparkR org.apache.spark.SparkException:R 工作人员意外退出
- java - 获取枚举值数组少指定项
- c++ - 在 QGraphicsScene 中通过鼠标位置获取 QGraphicsItem
- c++ - 如何从终端分离,以便 git 中的 post-receive 钩子完成
- python - Keras Sequential - ValueError:检查目标时出错:预期dense_3具有形状(无,45)但得到的数组具有形状(2868700,1)
- java - 运行来自多个版本但具有相同名称和相同类名的几个 jar
- android - 为什么我不能使用 if 或打开 JSONObject?