2016-04-14 31 views
0

對不起,我有一個關於Bootstrap的小問題。如何讓Boostrap上的一個元素內的元素比col更寬?

我試圖做一個網站響應和我有4列這樣的一行:

股利「seeMore」默認是隱藏的,並且在點擊boxToggle元素,它顯示塊一個slideToggle。這工作完美。

我的問題是,我希望div「seeMore」適合100%的行(如col-lg-12)。

我試圖把col「lg-3」以外的div「seeMore」製作成col-lg-12,它在大屏幕上工作正常,但在平板電腦和手機上卻損壞了,因爲div不在他的祖先。

$(document).ready(function() { 
 
    $("#boxToggle").click(function() { 
 
    $(".seeMore").slideToggle("slow"); 
 
    }); 
 
});
@import url(https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css); 
 

 
body { 
 
    font: arial sans-serif; 
 
} 
 

 
.wrapper { 
 
    width: 1280px; 
 
    margin: 0 auto; 
 
} 
 

 
.box { 
 
    background: pink; 
 
    color: #fff; 
 
    padding: 10px; 
 
} 
 

 
.box-body { 
 
    cursor: pointer; 
 
    height: 100px; 
 
} 
 

 
.seeMore { 
 
    display: none; 
 
    background: grey; 
 
    color: #fff; 
 
    padding: 10px; 
 
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> 
 
<div class="row"> 
 

 
<div class="col-lg-3 col-md-8 col-sm-6 col-xs-12"> 
 

 
    <div class="box box-int box-options"> 
 

 
    <div class="box-header"> 
 
     <h2>Title here</h2> 
 
    </div> 
 
        
 
    <div class="box-body" id="boxToggle"> 
 
     <div class="layout no-padding"> 
 
     <p>Some text here</p>    
 
     </div> 
 
    </div> 
 
        
 
    </div> 
 

 
    <div class="seeMore"> 
 
    <div class="txt"> 
 
     <h2>Some title here</h2> 
 
     <p>Blablabla</p> 
 
    </div>   
 
    </div> 
 

 
</div> 
 

 
    </div>

我做了一個codePen太多,如果你想看到:http://codepen.io/puzzleland/pen/BKrVJe

謝謝:)

+0

你行只與上4所定義一列。在你的筆中,col-lg-3覆蓋了所有其他的圖像。你需要多個列div。 –

回答

1

我希望我理解你正在努力實現正確的。如果你想.seeMore div來適應整個行的寬度可以從外層div移動列類聲明內的div像這樣:

<div class="wrapper"> 

    <div class="row"> 

    <div> <!-- Delete the class from here and put the declaration inside .box and .seeMore --> 

     <div class="box box-int box-options col-lg-3 col-md-8 col-sm-6 col-xs-12"> 

     <div class="box-header"> 
      <h2>Title here</h2> 
     </div> 

     <div class="box-body" id="boxToggle"> 
      <div class="layout no-padding"> 
      <p>Some text here</p> 
      </div> 
     </div> 

     </div> 

     <div class="seeMore col-xs-12"> 
     <div class="txt"> 
      <h2>Some title here</h2> 
      <p>Blablabla</p> 
     </div> 
     </div> 

    </div> 

    </div> 

</div> 
+0

這比我的(現在刪除的)答案更好。然而,我想做的一個改變是,我會用'seeMore col-xs-12'替換'seeMore col-lg-12 col-md-12 col-sm-12 col-xs-12'。如果最小尺寸設置爲12,所有其他尺寸需要爲12,則額外的聲明是多餘的。 –

+1

@JosephMarikle謝謝你的建議約瑟夫,你是對的。我正在編輯我的答案。 – fbid

+0

感謝您的回覆,但我已經嘗試過這種方法,但它不適用於小型設備,因爲我希望div「seeMore」正好位於div「框」下方。如果我喜歡你說的話,小設備上的div「seeMore」出現在另一個元素下面。 您可以嘗試在codePen上添加更多列以查看結果。我會做同樣的:) 再次感謝 – Puzzleland

相關問題