Left aligned caption for center aligned responsive image

北城余情 提交于 2019-12-23 03:06:44

问题


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?


回答1:


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>


来源:https://stackoverflow.com/questions/30113259/left-aligned-caption-for-center-aligned-responsive-image

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!