css - 如何使用 Bootstrap 3 将两个图像并排居中?

标签 css twitter-bootstrap

我似乎无法将类“social”的两个图像并排放置在“col-sm-4”类列的中心。相反,它们会随着屏幕尺寸的减小而堆叠。有什么想法可以响应式地执行此操作吗?

HTML

<div class="container-fluid">
     <div class="row" style="border-top: 0">
          <!-- Profile info -->
          <div class="col-sm-4 col-sm-offset-4">
               <img class="img-circle img-responsive" src="images/callum.jpg">
               <h1 class="text-center" style="color: #3FA2B2">Callum Messiter</h1>
               <p class="text-center">100-trillion cells and 100-billion neurons defying the 1 in 10<sup>2,685,000</sup> chance of me existing.</p> 
               <img class="social" src="images/twitter.png">
               <img class="social" src="images/github.png">
          </div>
     </div>
</div>

CSS

.row{
   border-top: 1px solid #808080;
   padding-left: 10px;
   padding-right: 10px;
   padding-bottom: 10px;
}

.col-sm-4{
   height: 450px;
}

.img-circle{
   height: 200px;
   width: 200px;
   margin: 0 auto;
   position: relative;
   top: 40px;
   border: 2px solid white;
}

.text-center{
   font-family: helvetica;
   color: white;
   position: relative;
   top: 50px;
}

span{
   font-weight: bold;   
   background-color: #e6e6e6;
   color: #3FA2B2;
   padding: 3px 7px 3px 7px;
}

.social{
   height: 50px;
   width: 50px;
   margin: 0 auto;
}

最佳答案

在 img 之前添加类 text-center。像这样

<div class="text-center">
  <img class="social" src="https://files.allaboutbirds.net/wp-content/themes/html5blank-stable/images/blue-winged-warbler.jpg">
  <img class="social" src="https://files.allaboutbirds.net/wp-content/themes/html5blank-stable/images/blue-winged-warbler.jpg">
</div>

此处演示 https://jsfiddle.net/ff9g43t8/

关于css - 如何使用 Bootstrap 3 将两个图像并排居中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38689159/

相关文章:

html - 我应该如何使用 styled-component 解决这些样式问题

html - 使用 CSS3 从右到左排列/重复 Div

javascript - Bootstrap Modal-Manager 禁用溢出

html - css : buttons float to the top. 如何水平对齐它们?

html - CSS 置顶,然后滚动回到顶部

javascript - Bootstrap AngularJS 模式正确重定向用户,但页面看起来黑了

javascript - 当元素是 col-sm-6 或 col-sm-4 的一部分时,我可以调整它吗?

css - bootstrap popover z-index 的问题

javascript - 折叠 Bootstrap 侧边栏

javascript - 使用javascript设置图像位置,并不总是正确放置