html - Bootstrap 按钮不居中

标签 html css twitter-bootstrap

我用 Bootstrap 构建了这个按钮,但它们没有居中。 我会附上一张有问题的照片。我是 Bootstrap 的新手,因为我是自己编写 css 的。 buttons 代码:

HTML/CSS

  .social {
  bottom: 0;
  left: 0;
  margin: 10px;
  position: absolute;
}

.fa-social {
  background: #2098f5;
  border: 0px solid #2098f5;
  color: rgb(255, 255, 255);
  height: 42px;
  line-height: 45px;
  text-align: center;
  width: 42px;
}

.fa-social:hover {
  color: #2098f5;
<div class="social">
  <a href="https://www.facebook.com"><i class="fa fa-facebook fa-2x fa-social"></i></a>
  <a href="https://www.twitter.com"><i class="fa fa-twitter fa-2x fa-social"></i></a>
  <a href="https://www.linkedin.com"><i class="fa fa-linkedin fa-2x fa-social"></i></a>
  <a href="https://www.plus.google.com"><i class="fa fa-google-plus fa-2x fa-social"></i></a>
</div>

最佳答案

简单地将 btn 类添加到您的 anchor(a) 标签中,如下所示

        <div class="social">
            <a href="https://www.facebook.com" class="btn btn-primary"><i class="icon-facebook fa-2x fa-social"></i></a>
            <a href="https://www.twitter.com" class="btn btn-primary"><i class="icon-twitter fa-2x fa-social"></i></a>
            <a href="https://www.linkedin.com" class="btn btn-primary"><i class="icon-linkedin fa-2x fa-social"></i></a>
            <a href="https://www.plus.google.com" class="btn btn-primary"><i class="icon-google-plus fa-2x fa-social"></i></a>
        </div>

Note: Here i have also used btn-primary for just color you can skip or set default.

关于html - Bootstrap 按钮不居中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47599075/

相关文章:

jquery - 当函数在浏览器上运行时如何获取值

javascript - 如何使用 Vue JS 遍历数组的值?

PHP:在html页面上显示表格内容

javascript - 两列中的三个 div - 等高

html - 我无法更改从 Google 字体复制的字体样式的字体大小

html - 使某些元素可能消失的菜单居中

javascript - 如何用sass为iphone 414px写断点?

html - 字体未在 HTML 中应用

html - 中心导航元素 Bootstrap

javascript - 将div转换为图片,在javascript中的bootstrap modal中显示