简体   繁体   English

左对齐标题用于中心对齐的响应图像

[英]Left aligned caption for center aligned responsive image

I can't make it work with Bootstrap 3. 我无法使其与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/ 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>

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

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