简体   繁体   English

Bootstrap 3列,具有图像和文本响应功能

[英]Bootstrap 3 columns with image & text responsive

The code below displays 3 columns, each with an image and text that resize down on a smaller screen and finally to 1 column on a smartphone. 下面的代码显示3列,每列的图像和文本在较小的屏幕上缩小尺寸,最后在智能手机上变为1列。 There are 2 problems : 1/ on the smallest screen, the image is too big and 2/ the text is under the image (like on the big screen) but I want it on the side of the image (half size of the smallest screen). 有2个问题:1 /在最小的屏幕上,图像太大,2 /文本在图像下方(如在大屏幕上),但我希望它在图像的侧面(最小的屏幕一半) )。

I looked at many example, but I can not find something simple... 我看了很多例子,但找不到简单的东西...

How can I achieve this easily with Bootstrap? 如何通过Bootstrap轻松实现这一目标?

<div class="container BSC_Angel">
  <div class="row">
    <div class="col-md-12 text-center">
      <div class="col-sm-4 text-center" style="">
        <div>image 1</div>
        <div>text 1</div>
      </div>
      <div class="col-sm-4 text-center" style="">
        <div>image 2</div>
        <div>text 2</div>
      </div>
      <div class="col-sm-4 text-center" style="">
        <div>image 3</div>
        <div>text 3</div>
      </div>
    </div>
  </div>
</div>

You can use CSS Flexbox . 您可以使用CSS Flexbox

Have a look at this Codepen . 看看这个Codepen

Or have a look at the snippet below ( use full screen to view this properly ): 或查看下面的代码段( use full screen to view this properly ):

 .content-holder { display: flex; flex-direction: column; align-items: center; justify-content: center; margin: 20px 0; } /* On Mobiles (screen width <= 767px) */ @media screen and (max-width: 767px) { .content-holder { flex-direction: row; } .text-div { margin-left: 10px; } } 
 <link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/> <div class="container BSC_Angel"> <div class="row"> <div class="col-md-12 text-center"> <div class="col-sm-4 text-center" style=""> <div class="content-holder"> <div class="img-div"><img src="http://placehold.it/100x100" alt=""></div> <div class="text-div">Text 1</div> </div> </div> <div class="col-sm-4 text-center" style=""> <div class="content-holder"> <div class="img-div"><img src="http://placehold.it/100x100" alt=""></div> <div class="text-div">Text 2</div> </div> </div> <div class="col-sm-4 text-center" style=""> <div class="content-holder"> <div class="img-div"><img src="http://placehold.it/100x100" alt=""></div> <div class="text-div">Text 3</div> </div> </div> </div> </div> </div> 

Hope this helps! 希望这可以帮助!

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM