2017-07-31 70 views
-2

我需要將一個框與引導列的左下角對齊。謝謝你的幫助。如何在Bootstrap列中將元素對齊到底部?

How I need it

的問題是,該列沒有限定的高度。

+1

父相對而言,並在方塊中出現ute和left:0和bottom:0 –

+0

[使用CSS在div底部對齊按鈕的可能的副本](https://stackoverflow.com/questions/5817233/align-button-at-the-bottom-of-div -using-css) –

+0

發佈你的代碼伴侶。所以我們可以幫助你。 :) –

回答

1

.bottomdiv { 
 
    border: 1px solid red; 
 
    height: 50px; 
 
    width: 50px; 
 
    position:absolute; 
 
    left:0; 
 
    bottom:0; 
 
} 
 
.col-md-6.col-sm-6.col-xs-6 { 
 
    display: table-cell; 
 
    height: auto; 
 
    border: 1px solid black; 
 
    float: none; 
 
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> 
 
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> 
 
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/> 
 
<div class="container"> 
 
    <div class="row"> 
 
     <div class="parent"> 
 
     <div class="col-md-6 col-sm-6 col-xs-6"> 
 
      <div class="bottomdiv"> 
 
      </div>    
 
     </div> 
 
     <div class="col-md-6 col-sm-6 col-xs-6"> 
 
      <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p> 
 
     </div> 
 
    </div> 
 
</div></div>

+0

@Radek Homola檢查我的答案。如有任何疑問,請告知我。 – Dhaarani

+0

完美運作!謝謝! –

+0

@Radek Homola歡迎 – Dhaarani

1

您可以將該列設置爲flexbox並將該元素對齊到最後。

.row { 
 
    background: red; 
 
} 
 

 
.col-6-md { 
 
    background: lightblue; 
 
    height: 200px; 
 
    display: flex; 
 
} 
 

 
.bottom { 
 
    background: green; 
 
    align-self: flex-end; 
 
    width: 100px; 
 
    height: 50px; 
 
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" /> 
 
<div class="row"> 
 
    <div class="col-6-md"> 
 
    <div class="bottom">Bottom</div> 
 
    </div> 
 
</div>

+0

哦,我發現了這個問題。高度必須保持靈活。 –

0

您也可以嘗試使用絕對CSS功能 .bottom position:absolute;bottom:0;left:0; 然後檢查的位置,改變它適合你