繁体   English   中英

如何获取jQuery的标题文本以使其与图像对齐?

[英]How do I get the caption text of the jQuery to align with the image?

我对传送带有问题。 我想使标题与图像具有相同的宽度,但现在将其设置为与内部项类相同的宽度。

我得到以下效果:

在此处输入图片说明

有没有一种方法可以将标题设置为居中(并与图像对齐)?

我的标记是:

<div id="myCarousel" class="carousel slide">
  <!-- Carousel items -->
  <div class="carousel-inner">
    <div class="active item">
      <div class="inner-item">
        <img src="img/1.jpg">
      </div>
      <div class="carousel-caption">
        <p>Caption</p>
      </div>
    </div>
    <div class="item">
      <div class="inner-item">
        <img src="img/1.jpg">
      </div>
       <div class="carousel-caption">
        <p>Caption text here</p>
      </div>
    </div>
    <div class="item">
      <div class="inner-item">
        <img src="img/1.jpg">
      </div>
       <div class="carousel-caption">
        <p>Caption text here</p>
      </div>
    </div>
  </div>
  <!-- Carousel nav -->
  <a class="carousel-control left" href="#myCarousel" data-slide="prev">&lsaquo;</a>
  <a class="carousel-control right" href="#myCarousel" data-slide="next">&rsaquo;</a>
</div>

如果我正确理解您的问题,为什么不使用text-align:center; 用于标题,并将宽度更改为图像的宽度

.carousel-caption
{
    text-align:center;
    width:800px; 
    /*If you are having aligning problems and the position is absolute or relative use left:some_number px or margin if not absolute */ 

}

我希望这可以帮助:)

暂无
暂无

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

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