아래와 같은 div가있는 페이지가 있습니다.
<div id="container">
<div id="A">
</div>
<div id="B">
<div id="B1"></div>
<div id="B2">B2</div>
</div>
<div id="C"></div>
<div id="D">
</div>
</div>
스타일링으로;
html, body {
margin: 0;
padding: 0;
border: 0;
}
#B, #C, #D {
position: absolute;
}
#A{
top: 0;
width: 100%;
height: 35px;
background-color: #99CC00;
}
#B {
top: 35px;
width: 200px;
bottom: 35px;
background-color: #999999;
z-index:100;
}
#B2 {
margin-top: -35px;
bottom: 0;
background-color: #FFFFFF;
width: 200px;
overflow: scroll;
}
#B1 {
height: 35px;
width: 35px;
margin-left: 200px;
background-color: #CC0066;
}
#C {
top: 35px;
left: 200px;
right: 0;
bottom: 35px;
background-color: #CCCCCC;
}
#D {
bottom: 0;
width: 100%;
height: 35px;
background-color: #3399FF;
}
B2
전체 div B
(녹색 테두리로 표시됨 )를 채우거나 늘리기 위해 div의 높이를 조정하고 바닥 글 div D를 교차하고 싶지 않습니다. 여기 작동하는 바이올린 데모 (업데이트 됨)가 있습니다. 어떻게 해결할 수 있습니까 ??
답변
간단히 추가 height: 100%;
에 #B2
스타일. min-height
필요하지 않아야합니다.
답변
당신이 가지고 있다고 가정
<body>
<div id="root" />
</body>
일반 CSS를 사용하면 다음을 수행 할 수 있습니다. 작동하는 앱 https://github.com/onmyway133/Lyrics/blob/master/index.html보기
#root {
position: absolute;
top: 0;
left: 0;
height: 100%;
width: 100%;
}
Flexbox를 사용하면 다음을 수행 할 수 있습니다.
html, body {
height: 100%
}
body {
display: flex;
align-items: stretch;
}
#root {
width: 100%
}
답변
“min-height”속성
사용 패딩, 여백 및 테두리에주의하십시오. 🙂
html, body {
margin: 0;
padding: 0;
border: 0;
}
#B, #C, #D {
position: absolute;
}
#A{
top: 0;
width: 100%;
height: 35px;
background-color: #99CC00;
}
#B {
top: 35px;
width: 200px;
bottom: 35px;
background-color: #999999;
z-index:100;
}
#B2 {
min-height: 100%;
height: 100%;
margin-top: -35px;
bottom: 0;
background-color: red;
width: 200px;
overflow: scroll;
}
#B1 {
height: 35px;
width: 35px;
margin-left: 200px;
background-color: #CC0066;
}
#C {
top: 35px;
left: 200px;
right: 0;
bottom: 35px;
background-color: #CCCCCC;
}
#D {
bottom: 0;
width: 100%;
height: 35px;
background-color: #3399FF;
}
답변
내 목적에 적합한 것은 항상 전체 브라우저 창 내에 고정 된 양으로 제한되는 div를 만드는 것이 었습니다.
적어도 firefox에서 효과가 있었던 것은
<div style="position: absolute; top: 127px; left: 75px;right: 75px; bottom: 50px;">
실제 창을 강제로 스크롤하지 않는 한 div는 모든 크기 조정 중에 창 가장자리에 대한 경계를 유지합니다.
이것이 누군가 시간을 절약하기를 바랍니다.
