我希望能够在内容折叠到中间右侧时在页面内滚动(内容在单击侧边栏标签时折叠/转换)。我不希望有主页滚动。
这是一个codepen,但由于界面大小,定位已关闭, http://codepen.io/anon/pen/XXKEpE
body {
margin: 0;
padding: 0;
}
.box {
width: 600px;
height: 600px;
float: left;
border: dotted 1px black;
margin-left: 200px;
background-color: green;
}
.page-content {
position: relative;
z-index: 1;
background-color: pink;
transition: .2s ease;
transform: scale(1);
transform-origin: right center;
overflow: scroll;
height: 100%;
}
.toggle {
text-decoration: none;
font-size: 30px;
color: black;
transition: .2s ease;
position: fixed;
top: 20px;
left: 20px;
z-index: 2;
}
.sidebar {
position: fixed;
top: 0px;
bottom: 0px;
left: 0px;
width: 120px;
padding: 30px;
background: #333;
z-index: 0;
}
li {
color: rgba(255, 255, 255, 0.8);
font-family: sans-serif;
font-size: 16px;
margin-bottom: 16px;
-webkit-font-smoothing: atialiased;
cursor: pointer;
}
li:hover {
color: rgba(255, 255, 255, 1);
}
#sidebartoggler {
display: none;
}
#sidebartoggler:checked + .page-wrap .toggle {
left: 200px;
}
#sidebartoggler:checked + .page-wrap .page-content {
transform: scale(0.7);
}
<body>
<input type="checkbox" id="sidebartoggler" name=" " value="" />
<div class="page-wrap">
<label for="sidebartoggler" class="toggle">☰</label>
<div class="page-content">
<div class="box"></div>
<div class="box"></div>
<div class="box"></div>
<div class="box"></div>
<div class="box"></div>
<div class="box"></div>
<div class="box"></div>
<div class="box"></div>
</div>
<div class="sidebar">
<ul>
<li>Home</li>
<li>Projects</li>
<li>Clients</li>
<li>Blog</li>
<li>Contact</li>
</ul>
</div>
</div>
答案 0 :(得分:2)
.page-wrap, body, html{
height:100%;
}
您的css需要height:100%
才能使用此功能。基本上如果你想制作100%的页面高度,它的所有祖先都必须是100%
答案 1 :(得分:0)
你可以添加
page-wrap{
height: 100vh;
}