2013-03-12 52 views
0

我遇到carousel問題。我想使標題的寬度與圖像的寬度相同,但現在它的寬度與內部項目類的寬度相同。如何獲取jQuery的標題文本以與圖像對齊?

我得到以下效果:

enter image description here

有沒有一種方法來設置標題,這樣它就居中(並與圖像對齊)?

我的標記是:

<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> 
+0

請提供一個小提琴 – honk31 2013-03-12 17:57:49

+0

這看起來是'.carousel-caption' CSS的問題。你還沒有提供。 – dev 2013-03-12 17:59:24

+0

@vletech這個css類是由http://twitter.github.com/bootstrap/提供的 – Sheldon 2013-03-12 18:07:44

回答

1

如果我正確理解你的問題 爲什麼你不使用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 */ 

} 

我希望這可以幫助:)

+0

對不起,只是使標題大,並對齊其中的文字。 – Sheldon 2013-03-12 18:08:50

+0

你需要使它在中心,並更改寬度 – Sedz 2013-03-12 18:10:11

+0

@Sheldon,從CSS中刪除高度對不起 – Sedz 2013-03-12 18:10:52