页面结构:
<body>
<header></header>
<section></section>
<scroller-wrap>
<scroller-content></scroller-content>
</scroller-wrap>
</body>
问题
如何让header
、section
和scroller-wrap
的高度正好为100vh
,是不是必须要用js辅助才能实现
<body>
<header></header>
<section></section>
<scroller-wrap>
<scroller-content></scroller-content>
</scroller-wrap>
</body>
如何让header
、section
和scroller-wrap
的高度正好为100vh
,是不是必须要用js辅助才能实现
让页面高度100%,其余板块平分100%的高度就可以了。
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>test</title>
<style>
*{padding:0; margin:0;}
html,body{height:100%;}
.wrap{height:100%;}
.top{height:50%; background-color:#666;}
.scroll{height:50%; overflow-y:scroll; background-color:#999;}
.scroll-content{height:600px; background-color:#000; color:#fff;}
</style>
</head>
<body>
<div class="wrap">
<div class="top"></div>
<div class="scroll">
<div class="scroll-content">
我是滚动区域
</div>
</div>
</div>
</body>
</html>
13 回答13.1k 阅读
3 回答1.5k 阅读✓ 已解决
7 回答2.3k 阅读
5 回答1.6k 阅读
5 回答1.9k 阅读✓ 已解决
3 回答1.4k 阅读✓ 已解决
6 回答1.4k 阅读✓ 已解决
用我评论里的思路解决了,在这里copy一下吧。