简体   繁体   中英

Left aligned caption for center aligned responsive image

I can't make it work with Bootstrap 3.

I have a center aligned responsive image like this:

<img class="img-responsive center-block" src="">

and I want to add caption, which will be left aligned under the image.

Any ideas? 在此处输入图片说明

This one was a lot trickier than i thought.. So the first thing to do was wrap the image in a span, which would control the size of the width of the caption. From here it got complicated because having the wrap maintain the width of the image is easy but you lose the ability to keep it centered and responsive...

https://jsfiddle.net/mk7on98L/19/

      <span class="text-center center-block" style="max-width:100%">
    <span data-caption="Some sample text. Some sample text." class="img-wrapper text-left">
      <img class="img-responsive" src="http://placehold.it/350x150">
    </span>
  </span>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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