2017-02-01 7 views
3

私のナビゲーションバーを反応させようとしていますが、背景があり、横に100%幅を追加できません。固定幅の通知パネルがあり、100%の幅をNavbarに追加すると、それはコンテナの幅に広がり、その下に通知パネルが表示されます。 私が必要とするのは、ページの右側に固定幅の通知パネルを置くことです。画面の幅を小さくすると、通知パネルはナビバーの幅を狭くしなければなりません(navbarは応答します)。イムは、実際の簡単な私のコードを取り付ける:ナビゲーションバーの背景画像の応答性、右側に別のコンテナがある

<!DOCTYPE html> 
<html> 
<head> 
<meta name="viewport" content="width=device-width, initial-scale=1.0"> 
<link rel="stylesheet" type="text/css" href="proba.css"> 
</head> 
<body> 
    <div class="navbar"> 
     <ul> 
     </ul> 
    </div> 
    <div class="notification-panel"> 
    </div> 
</div> 
</body> 
</html> 

CSSコード:

.container{ 
    max-width:1200px; 
    height:1000px; 
    margin: 0px auto; 
    padding:0px; 
    border:1px solid red; 
} 

.navbar{ 
    width:100%; /*there should be the 100% to make the navbar responsive*/ 
    height: 58px; 
    background-image: url('menu.png'); 
    background-size: 100% 100%; 
    float:left; 
    margin-left:5px; 
} 

.notification-panel { 
    float:left; 
    width:230px; 
    height:800px; 
    border:1px solid red; 
} 

ありがとうみんな

+0

通知パネルから残されたすべての利用可能なスペース取るために:CALC(100% - 230px) ; ' –

答えて

1
を使用でき

calc()

.container { 
 
    max-width: 1200px; 
 
    height: 1000px; 
 
    margin: 0px auto; 
 
    padding: 0px; 
 
    border: 1px solid red; 
 
} 
 
    
 
.navbar { 
 
    width: calc(100% - 235px); 
 
    height: 58px; 
 
    background-image: url('menu.png'); 
 
    background-size: 100% 100%; 
 
    float: left; 
 
    margin-left: 5px; 
 
} 
 
    
 
.notification-panel { 
 
    float: left; 
 
    width: 230px; 
 
    height: 800px; 
 
    border: 1px solid red; 
 
    box-sizing: border-box; 
 
}
<div class="container"> 
 
<div class="navbar"> 
 
    <ul> 
 
    </ul> 
 
</div> 
 
<div class="notification-panel"> 
 
</div> 
 
</div>

またはそれが成長する.navbarflex-grow: 1;とフレキシボックスは、あなたが `幅を使用することができます

.container { 
 
    max-width: 1200px; 
 
    height: 1000px; 
 
    margin: 0px auto; 
 
    padding: 0px; 
 
    border: 1px solid red; 
 
    display: flex; 
 
} 
 
    
 
.navbar { 
 
    flex-grow: 1; 
 
    /*there should be the 100% to make the navbar responsive*/ 
 
    height: 58px; 
 
    background-image: url('menu.png'); 
 
    background-size: 100% 100%; 
 
} 
 
    
 
.notification-panel { 
 
    width: 230px; 
 
    height: 800px; 
 
    border: 1px solid red; 
 
    box-sizing: border-box; 
 
}
<div class="container"> 
 
    <div class="navbar"> 
 
    <ul> 
 
    </ul> 
 
    </div> 
 
    <div class="notification-panel"> 
 
    </div> 
 
</div>

+0

ありがとう、幅:calc(100% - 235px);働いた – Looz

関連する問題