2017-02-01 2 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>

,451,515,

정도가 증가 할 .navbarflex-grow: 1;와 인 flexbox 당신은`폭 사용할 수 있습니다

.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