html - 使用 justify-content 在 div 中定位按钮
问题描述
我正在尝试使用 justify-content 将一个按钮放在 div 的开头,将另一个按钮放在末尾,
但我注意到,只有在 div 而不是 btn 本身上调用 justify 内容才有效,所以下面是我所写的,我知道它不起作用。
任何提示将不胜感激
<!DOCTYPE html>
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.slim.js"></script>
<title>Container justify</title>
<div class="d-flex justify-content">
<button class="btn justify-content-start btn-default">button1</button>
<button class="btn justify-content-end btn-default">button2</button>
</div>
解决方案
您可以使用 inline-block 元素以更常用的方式执行此操作,如下所示:
.d-flex {
display: inline-block;
width: 100%;
}
.justify-content-start {
float: left;
}
.justify-content-end {
float: right;
}
如果需要,您可以更改 html 页面中的类,我只是使用了您提供的类。
推荐阅读
- python - Python在全局变量中导入pymysql变量?
- flutter - 当我只有一个 Stream 时,如何使用 Image.memory 在 Flutter Web 中显示图像
- >? 数据类型?
- http - 如何使用频道保持实时服务器命令
- ruby-on-rails - 始终将新文本附加到列中的当前文本
- python - 如何在每次请求 Flask 中的静态资源后运行函数?
- bash - 如何查找文件并作为源脚本运行?
- javascript - 我在尝试在 AngularJs 中导出服务时遇到问题,说 Unknown provider: loginServiceProvider <- loginService <- LoginController
- python-3.x - 向 Twillio 添加代理
- email - Kolab Service Does not Start/No Emails Can be Sent/Recieved
- google-cloud-platform - 撤销/使 .boto 文件(gsutil 配置)中生成的 oauth2 刷新令牌无效