简体   繁体   English

如何将两个图像与Bootstrap 3并排居中?

[英]How can I center two images side-by-side with Bootstrap 3?

I can't seem to get the two images of class 'social' side-by-side, central to the column of class 'col-sm-4'. 我似乎无法并排获得“社会”类的两个图像,它们在“ col-sm-4”类的列的中心。 Instead they stack as the screen size decreases. 相反,它们会随着屏幕尺寸的减小而堆叠。 Any ideas how I can do this responsively? 有任何想法我该如何快速地做到这一点?

HTML 的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 的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;
}

Add class text-center before img. 在img之前添加class text-center like this 像这样

<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>

DEMO HERE https://jsfiddle.net/ff9g43t8/ 在这里演示https://jsfiddle.net/ff9g43t8/

Try: 尝试:

.social {
 display: inline-block;
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为什么我不能得到两个 <p> 元素可以并排并按中心对齐? - Why can't I get two <p> elements to be side-by-side and aligned by center? 用于并排显示图像的 HTML 引导程序? - HTML bootstrap for displaying images side-by-side? 如何使并排锚和锚图像标签垂直居中? - How can I vertically center side-by-side anchor and anchor-image tags? 将两个图像与字幕并排放置 - Centering two images side-by-side with captions 无法在CSS中并排显示图像组(类图像) - Can't Center Group of images (Class images) side-by-side in CSS 如何并排获得两个表单域,每个图例位于该域上方? - How can I get two form fields side-by-side, with each legend above the field? 我怎么能有两个<div>元素并排(2列)</div><div id="text_translate"><p> 我想并排放置两个标签,就像是两列一样。</p><p> 到目前为止我有</p><pre>&lt;div id="wrapper"&gt; &lt;div id="1"&gt;text here&lt;/div&gt; &lt;div id="2"&gt;text here&lt;/div&gt; &lt;div style="clear:both"&gt;&lt;/div&gt; &lt;/div&gt;</pre><p> 我遇到的困难是 div 的 CSS。 有什么帮助吗?</p></div> - How can I have two <div> elements side-by-side (2 columns) 我怎样才能在 React 应用程序的页脚中并排显示我的两个图标? - How can i get my two icons side-by-side in my footer in React app? 我该如何显示? <ul> 作为使用CSS的两个并排列? - How can I display a <ul> as two side-by-side columns using CSS? 如何在两个并排的div中垂直居中显示文本? - How can I vertically center text in two side by side divs?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM