【发布时间】:2021-09-20 18:54:04
【问题描述】:
代码沙盒:
https://codesandbox.io/s/eloquent-haibt-1bnib?file=/src/main.js
我想将按钮中的- 文本居中,但找不到方法。
html
<button class="round-button align-middle mr-1">
<span>-</span>
</button>
css
.round-button {
min-width: 20px;
max-height: 20px;
text-decoration: none;
display: inline-block;
outline: none;
cursor: pointer;
border-style: none;
color: white;
background-color: #3498db;
border-radius: 100%;
overflow: none;
text-align: center;
padding: 0;
}
.round-button:before {
content: "";
display: inline-block;
vertical-align: middle;
}
【问题讨论】:
-
我看到了你的代码沙箱,看起来文本是居中的,但你需要增加按钮的宽度。
-
@Random COSMOS 请查看我上面的图片
-
使用显示弹性
-
你的意思是垂直居中,如果是这样,那么正如 Muzamil301 所说,使用 display: flex;和对齐项目;中心;
-
我相信@Rahul Kapuriya 的答案更完整、更具描述性,应该被选为答案。
标签: css vue.js bootstrap-4