2017-01-09 12 views
0

私はブートストラップが初めてで、box2box3 divをページの右側の列の下に移動したいと考えています。 box2box3を超える空の行に頼らなくても、これを行う方法を考えることができません。ここに私の現在のhtml次のとおりです。ブートストラップ - 行をページの末尾に移動

<!DOCTYPE html> 
<html lang="en"> 
    <head> 
     <meta charset="utf-8" /> 
     <meta http-equiv="X-UA-Compatible" content="IE=edge" /> 
     <meta name="viewport" content="width=device-width, initial-scale=1.0"/> 
     <link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" /> 

     <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> 

     <style type="text/css"> 

     .jumbotron { 
      text-align: center; 
      padding-bottom: 5px; 
     } 

     h2 { 
      margin: auto; 
     } 

     .box1 { 
      min-height: 450px; 
      border-style: dotted; 
     } 

     .box2 { 
      min-height: 150px; 
      margin-bottom: 10px; 
      border-style: dotted; 
     } 

     .box3 { 
      min-height: 30px; 
      border-style: dotted; 
     } 
     </style> 

    </head> 
    <body style="background:pink;"> 
      <div class="jumbotron" style="background:pink;"> 
       <h2>Lyrical</h2> 
      </div> 

      <div class="container-fluid"> 

       <div class="row"> 
        <div class="col-lg-6 col-lg-offset-3"> 
         <div class="box1">FORM</div> 
        </div> 

        <div class="col-lg-3"> 
         <div class="row"> 
          <div class="col-lg-12"> 
           <div class="box2">Description</div> 
          </div> 
         </div> 
         <div class="row"> 
          <div class="col-lg-12"> 
           <div class="box3">Credits</div> 
          </div> 
         </div> 
        </div> 
       </div> 
      </div> 
     </body> 
</html> 

は、ブートストラップグリッドを使用してこれを行う方法はありますか? ご迷惑をおかけして申し訳ありません。それはflexbox's align-selfと親の下部に要素をプッシュすることが可能である

答えて

1

この

<!DOCTYPE html> 
<html lang="en"> 
    <head> 
     <meta charset="utf-8" /> 
     <meta http-equiv="X-UA-Compatible" content="IE=edge" /> 
     <meta name="viewport" content="width=device-width, initial-scale=1.0"/> 
     <link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" /> 
     <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script> 
     <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> 
     <script> 
     $(document).ready(function(){ 
      var bottom1 = $('.box1').outerHeight(true); 
      var bottom2 = $('.right-sides-columns').outerHeight(true); 
      var topheight = bottom1 - bottom2; 
      $('.right-sides-columns').css("margin-top", topheight + "px"); 
     }); 
     </script> 
     <style type="text/css"> 

     .jumbotron { 
      text-align: center; 
      padding-bottom: 5px; 
     } 

     h2 { 
      margin: auto; 
     } 

     .box1 { 
      min-height: 450px; 
      border-style: dotted; 
     } 

     .box2 { 
      min-height: 150px; 
      margin-bottom: 10px; 
      border-style: dotted; 
     } 

     .box3 { 
      min-height: 30px; 
      border-style: dotted; 
     } 
     </style> 

    </head> 
    <body > 
      <div class="jumbotron" > 
       <h2>Lyrical</h2> 
      </div> 

      <div class="container-fluid"> 

       <div class="row"> 
        <div class="col-lg-6 col-lg-offset-3"> 
         <div class="box1">FORM</div> 
        </div> 

        <div class="col-lg-3 right-sides-columns"> 
         <div class="row"> 
          <div class="col-lg-12"> 
           <div class="box2">Description</div> 
          </div> 
         </div> 
         <div class="row"> 
          <div class="col-lg-12"> 
           <div class="box3">Credits</div> 
          </div> 
         </div> 
        </div> 
       </div> 
      </div> 
     </body> 
     </html> 
+0

感謝。これはうまくいきますが、位置が '絶対的なので、ページがサイズ変更されたときには拡大縮小されません。同じことをする方法はありますか?サイズを変更しないでください。 – ggordon

+0

@ggordon私は自分の答えを更新しました。それを達成するためにスクリプトを追加してください。 – vas

0

ない特定のブートストラップの回答が、より一般的なアプローチを試してみてください。返信用

.flex-row { 
 
    display: flex; 
 
    flex-direction: row; 
 
    align-items: flex-start; 
 
    height: 300px; 
 
} 
 
.flex-col { 
 
    background: rebeccapurple; 
 
} 
 
.flex-col--end { 
 
    align-self: flex-end; 
 
}
<div class="flex-row"> 
 
    <div class="flex-col"> 
 
    <p>Lorem Ipsum</p> 
 
    </div> 
 
    <div class="flex-col flex-col--end"> 
 
    <p>Dolor Sit</p> 
 
    </div> 
 
</div>

関連する問題