2016-11-02 7 views
1

私はコンテナクラスを持っています。そのクラスの中にはすべて私の要素があります。垂直バー(リンクパネル)とその横のdiv(control_panel)を含みます。私は私の垂直バーの高さを与えることを試みている:100%。コンテナクラスに100%の高さを与えなければならないことは分かっていますが、(control_panel)divはフッター(コンテナにない要素)の上を走ります。私は経験しているもののjsfiddleを作りましたが、実際のファイルのフッターはHTMLに動的に追加されているので、コンテナクラスには含めませんでしたのでご注意ください。垂直バーの高さを100%

また、ボディの高さを100%にしてみましたが、縦棒の親がコンテナであるため、ボディに縦棒の変更が反映されません。フッターまで100%の高さの垂直バーを実現できるようにするにはどうすればよいですか? Here's my jsFiddle

.container { 
 
    display: block; 
 
    margin: 0px auto; 
 
    width: 100%; 
 
} 
 
.footer { 
 
    display: block; 
 
    width: 100%; 
 
    height: 500px; 
 
    background-color: black; 
 
    margin-top: 0px; 
 
} 
 
html, 
 
body { 
 
    position: relative; 
 
    height: 100%; 
 
    background-color: #f2f2f2; 
 
} 
 
.control_panel { 
 
    position: relative; 
 
    display: inline-block; 
 
    width: 60%; 
 
    margin-left: 0px; 
 
} 
 
.control_title { 
 
    display: block; 
 
    background-color: white; 
 
    height: 100px; 
 
    margin-bottom: 30px; 
 
} 
 
.control_settings { 
 
    display: block; 
 
    background-color: white; 
 
    height: 900px; 
 
    width: 900px; 
 
} 
 
.link-panel { 
 
    position: relative; 
 
    float: left; 
 
    width: 30%; 
 
    height: 100%; 
 
    background-color: #333333; 
 
} 
 
.link-panel ul { 
 
    list-style-type: none; 
 
    font-size: 19px; 
 
    margin-top: 35px; 
 
} 
 
.link-panel li { 
 
    margin-top: 15px; 
 
}
<html> 
 

 
<body> 
 
    <div class="container"> 
 

 
    <div class='control_panel'> 
 
     <div class='control_title'> 
 
     <h2>Your Settings</h2> 
 
     </div> 
 

 
     <div class='control_settings'> 
 

 
     </div> 
 
    </div> 
 

 
    <div class="link-panel"> 
 
     <ul> 
 

 

 
     <li>Dashboard</li> 
 
     <hr> 
 
     <li>Blog</li> 
 
     <hr> 
 
     <li><span><b>|</b> Settings</span> 
 
     </li> 
 
     <hr> 
 
     <li>Contact Us</li> 
 

 

 
     </ul> 
 
    </div> 
 
    <!--End of link panel div--> 
 
    </div> 
 

 
    <div class='footer'> 
 

 
    </div> 
 
</body> 
 

 
</html>

+0

:#333333;' '.container'か? – Banzay

答えて

1

あなたは、子のdivは、あなたがこれを達成するために位置を使用することができ、100%の高さや、それぞれの親のdivのようにしたいです。

更新されたフィドルを参照してください。

あなたは `背景色を割り当てる場合はどう
.container { 
    display: block; 
    margin: 0px auto; 
    width: 100%; 
    padding-left:30%; 
    box-sizing:border-box; 
    position:relative; 
} 
.link-panel { 
    position: absolute; 
    float: left; 
    width: 30%; 
    height: 100%; 
    background-color: #333333; 
    left: 0; 
    top: 0; 
} 

+0

これはまさに私が欲しかったものです。ありがとうございました! – user2896120

1

.container { 
 
    display: block; 
 
    margin: 0px auto; 
 
    width: 100%; 
 
} 
 
.footer { 
 
    display: block; 
 
    width: 100%; 
 
    height: 500px; 
 
    background-color: black; 
 
    margin-top: 0px; 
 
} 
 
html, 
 
body { 
 
    position: relative; 
 
    height: 100%; 
 
    background-color: #f2f2f2; 
 
} 
 
.control_panel { 
 
    position: relative; 
 
    display: inline-block; 
 
    width: 60%; 
 
    height: 100%; // A CHANGE HERE 
 
    margin-left: 0px; 
 
} 
 
.control_title { 
 
    display: block; 
 
    background-color: white; 
 
    height: 100px; 
 
    margin-bottom: 30px; 
 
} 
 
.control_settings { 
 
    display: block; 
 
    background-color: white; 
 
    width: 900px; // REMOVED HEIGHT HERE 
 
} 
 
.link-panel { 
 
    position: relative; 
 
    float: left; 
 
    width: 30%; 
 
    height: 100%; 
 
    background-color: #333333; 
 
} 
 
.link-panel ul { 
 
    list-style-type: none; 
 
    font-size: 19px; 
 
    margin-top: 35px; 
 
} 
 
.link-panel li { 
 
    margin-top: 15px; 
 
}
<!-- Code order changed ---> 
 
<div class="container"> 
 
    <div class="link-panel"> 
 
    <ul> 
 
     <li>Dashboard</li> 
 
     <hr> 
 
     <li>Blog</li> 
 
     <hr> 
 
     <li><span><b>|</b> Settings</span> 
 
     </li> 
 
     <hr> 
 
     <li>Contact Us</li> 
 
    </ul> 
 
    </div> 
 
    <!--End of link panel div--> 
 
    <div class='control_panel'> 
 
    <div class='control_title'> 
 
     <h2>Your Settings</h2> 
 
    </div> 
 
    <div class='control_settings'> 
 
    </div> 
 
    </div> 
 
</div> 
 
<div class='footer'></div>

+0

これは、コンテンツをcontrol_settingsに追加するときには機能しません。 control_panelの高さがリンクパネルの高さよりも大きくなります。リンクパネルの高さを常にページの100%にしたい。 – user2896120

+0

右サイドパネルがスティッキーでいいですか? –

+0

はい、右のパネルはその場所から動かないはずです – user2896120

0
<html> 
<head> 
<style> 
html, body { 
    position: relative; 
    height: 100%; 
    background-color: #f2f2f2; 
} 
.left-container { 
    width: 30%; 
    position: fixed; 
    height: 100%; 
    left: 0; 
    top: 0; 
} 
.link-panel { 
    position: relative; 
    float: left; 
    width: 100%; 
    height: 100%; 
    background-color: #333333; 
} 
.link-panel ul { 
    list-style-type: none; 
    font-size: 19px; 
    margin-top: 35px; 
} 

.link-panel li { 
    margin-top: 15px; 
} 
.right-container { 
    width: 70%; 
    margin-left: 30%; 
    clear: right; 
    display: block; 
    height: 100%; 
} 
.control_panel { 
    position: relative; 
    display: inline-block; 
    width: 100%; 
    margin-left: 0px; 
} 
.control_title { 
    display: block; 
    background-color: white; 
    height: 50px; 
} 
h2 { 
    display: block; 
    font-size: 1.5em; 
    -webkit-margin-before: 0.83em; 
    -webkit-margin-after: 0.83em; 
    -webkit-margin-start: 0px; 
    -webkit-margin-end: 0px; 
    font-weight: bold; 
} 
.control_settings { 
    display: block; 
    background-color: white; 
    width: 100%; 
} 
.footer { 
    display: block; 
    width: 100%; 
    height: 500px; 
    background-color: black; 
    margin-top: 0px; 
    position: fixed; 
    top: 90%; 
    left: 0; 
} 
</style> 
</head> 
<body> 
    <div class="left-container"> 
     <div class="link-panel"> 
     <ul> 
     <li> Dashboard</li> 
      <hr> 
      <li> Blog</li> 
      <hr> 
      <li><span><b>|</b> Settings</span></li> 
      <hr> 
      <li> Contact Us</li> 
     </ul> 
     </div> 
    </div> 
     <!--End of link panel div--> 
     <div class="right-container"> 
     <div class='control_panel'> 
     <div class='control_title'> 
      <h2>Your Settings</h2> 
     </div> 
    </div> 

     <div class='control_settings'>Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32. 

The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from "de Finibus Bonorum et Malorum" by Cicero are also reproduced in their exact original form, accompanied by English versions from the 1914 translation by H. Rackham. 
Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32. 

The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from "de Finibus Bonorum et Malorum" by Cicero are also reproduced in their exact original form, accompanied by English versions from the 1914 translation by H. Rackham. 
Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32. 

The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from "de Finibus Bonorum et Malorum" by Cicero are also reproduced in their exact original form, accompanied by English versions from the 1914 translation by H. Rackham.Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32. 

The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from "de Finibus Bonorum et Malorum" by Cicero are also reproduced in their exact original form, accompanied by English versions from the 1914 translation by H. Rackham. 
</div> 
    </div> 

    <div class='footer'> 

    </div> 
    </body> 
</html> 
関連する問題