2016-06-26 14 views
3

固定のnavbarとsidemenuを作成しようとしていますが、スクロール可能なコンテンツペインを作成しようとしています。CSS navbar、サイドバー、コンテンツペイン

は私codepenを参照してください - スクロールするときhttp://codepen.io/anon/pen/jryKvY

しかし、私のコンテンツ・ペインの背景には、ちょうどオーバーフローコンテンツを埋めるないでしょう。

overflow: scrollをコンテンツペインのdivに定義することなく、これを修正する必要があります。

html { 
 
    box-sizing: border-box; 
 
} 
 
*, 
 
*::after, 
 
*::before { 
 
    box-sizing: inherit; 
 
} 
 
.container { 
 
    height: 100%; 
 
    position: static; 
 
    max-width: 100%; 
 
    margin-left: auto; 
 
    margin-right: auto; 
 
} 
 
.container::after { 
 
    clear: both; 
 
    content: ""; 
 
    display: block; 
 
} 
 
.container .navbar { 
 
    width: 100%; 
 
    height: 50px; 
 
    background: grey; 
 
    position: fixed; 
 
    z-index: 2; 
 
    top: 0; 
 
    right: 0; 
 
    bottom: 0; 
 
    left: 0; 
 
} 
 
.container .contentpane { 
 
    background: lightsalmon; 
 
    position: absolute; 
 
    top: 50px; 
 
    right: 0; 
 
    bottom: 0; 
 
    left: 250px; 
 
} 
 
.container .sidemenu { 
 
    background: lightblue; 
 
    width: 250px; 
 
    position: fixed; 
 
    z-index: 2; 
 
    top: 50px; 
 
    right: 0; 
 
    bottom: 0; 
 
    left: 0; 
 
}
<div class="container"> 
 

 
    <div class="navbar"> 
 
    navbar 
 
    </div> 
 

 
    <div class="contentpane"> 
 
    <h1>Content</h1> 
 
    <p>What is Lorem Ipsum? 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> 
 
    <p>What is Lorem Ipsum? 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> 
 
    <p>What is Lorem Ipsum? 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> 
 
    <p>What is Lorem Ipsum? 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> 
 
    <p>What is Lorem Ipsum? 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> 
 
    <p>What is Lorem Ipsum? 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> 
 
    <p>What is Lorem Ipsum? 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> 
 
    <p>What is Lorem Ipsum? 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> 
 
    <p>What is Lorem Ipsum? 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> 
 
    <p>What is Lorem Ipsum? 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> 
 
    <p>What is Lorem Ipsum? 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 class="sidemenu"> 
 
    menu 
 
    </div> 
 

 
<div>

答えて

2

あなたは代わりに、例えばhtmlまたはbody要素の背景を設定することができます

body { 
    background: lightsalmon; 
} 

それはそれの上にナビゲーションバーとサイドバーの背景と、背景がビューポート全体をカバーするようになりますので、それだけで、コンテンツパネルを設定して見えます。コンテンツがより短い場合でも、画面が大きい場合でも、つまりスクロールバーが不要な場合でも機能します。

jsFiddle

2

以前contentpanelを削除し、これを試してみてください、

.container > .contentpane { 
    background: lightsalmon; 
    top: 29px; 
    width:auto; 
    height:auto; 
    position:relative; 
    margin-left:242px;/*Set that equal to or less then the width of sidemenu*/ 


} 
関連する問題