css - 将跨度文本与 .btn 对齐

标签 css bootstrap-4

我正在使用下面的 .card 并在一段时间内获得文本“你喜欢这个”。与 hr 元素下方的 Like 和 Comment .btn-links 一致。

<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet"/>
<div class="card mx-auto mt-5" style="width:500px">
    <div class="card-body">
      <hr>
      <div>
        <button class="btn btn-link">Like</button>
        <span class="text-muted" style="">You liked this.</span>
        <button class="btn btn-link float-right">3  Comments</button>
      </div>
  </div>
</div>

我已经尝试了所有我能想到的。更改显示属性。使用边距或填充。调整字体高度。这些都没有用。我不确定如何让它对齐,我们将不胜感激。

我可能可以使用 float 甚至 flexbox 来让它工作,但这似乎太过分了,如果可能的话我宁愿不要这样做。谢谢。

最佳答案

你错过了垂直对齐,在你的 span 上使用 Bootstrap 类 align-middle

<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet"/>
<div class="card mx-auto mt-5" style="width:500px">
    <div class="card-body">
      <hr>
      <div>
        <button class="btn btn-link">Like</button>
        <span class="text-muted align-middle">You liked this.</span>
        <button class="btn btn-link float-right">3  Comments</button>
      </div>
  </div>
</div>

关于css - 将跨度文本与 .btn 对齐,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58267880/

相关文章:

html - 使用字体很棒的图标-导航栏不会崩溃

javascript - 像谷歌一样更改滚动网站

html - 样式 Bootstrap 4 自定义复选框

html - css 悬停动画在 icomoon 中不起作用

css - 如何定位按钮和下拉菜单 css-bootstrap

javascript - 鼠标悬停时显示导航

css - 如果添加 @font-face 或标准样式表链接,谷歌字体的不同呈现?

CSS 编译/压缩和 Source Maps v3

html - 调整我的 div 大小时,内容脱落,我得到一个滚动条来水平调整屏幕。 (站点宽)

html - 如何使用 CSS 使菜单像纸一样折叠?