我有一个很快速的问题。我已经将侧边栏div的高度设置为100%,但是每当我调整窗口大小时,使窗口高度最小,并且向下滚动侧边栏的高度不会到达页面底部。这是我在说什么的图片
这是我的代码:
<div class="wrapper">
<div class="top-bar">
<div class="search-input">
<form>
<div class="input-field">
<input type="text" placeholder="Search user" name="userPost">
</div>
</form>
</div>
</div>
<div class="side-bar">
<div class="sub-title">
<h3>ADMIN TOOLS<h3>
</div>
<div class="splitter"></div>
<div class="button">
<div class="button-container">
<form>
<input type="button" value="Dashboard" onclick="window.location.href='http://www.google.com'"/>
<i class="fas fa-tachometer-alt fa-lg" aria-hidden="true"></i>
</form>
</div>
</div>
<div class="button">
<div class="button-container">
<form>
<input type="button" value="Ban Panel" onclick="window.location.href='http://www.google.com'"/>
<i class="fas fa-ban fa-lg" aria-hidden="true"></i>
</form>
</div>
</div>
<div class="button">
<div class="button-container">
<form>
<input type="button" value="Warn Panel" onclick="window.location.href='http://www.google.com'"/>
<i class="fas fa-exclamation-circle fa-lg" aria-hidden="true"></i>
</form>
</div>
</div>
<div class="button">
<div class="button-container">
<form>
<input type="button" value="Gift Panel" onclick="window.location.href='http://www.google.com'"/>
<i class="fas fa-gift fa-lg" aria-hidden="true"></i>
</form>
</div>
</div>
<div class="button">
<div class="button-container">
<form>
<input type="button" value="User Info" onclick="window.location.href='http://www.google.com'"/>
<i class="fas fa-user fa-lg" aria-hidden="true"></i>
</form>
</div>
</div>
<div class="sub-title">
<h3>NEWS TOOLS<h3>
</div>
<div class="splitter"></div>
<div class="button">
<div class="button-container">
<form>
<input type="button" value="New Post" onclick="window.location.href='http://www.google.com'"/>
<i class="fas fa-file fa-lg" aria-hidden="true"></i>
</form>
</div>
</div>
<div class="button">
<div class="button-container">
<form>
<input type="button" value="Remove Post" onclick="window.location.href='http://www.google.com'"/>
<i class="fas fa-trash fa-lg" aria-hidden="true"></i>
</form>
</div>
</div>
<div class="sub-title">
<h3>OTHER<h3>
</div>
<div class="splitter"></div>
<div class="button">
<div class="button-container">
<form>
<input type="button" value="Game Statistics" onclick="window.location.href='http://www.google.com'"/>
<i class="fas fa-chart-line fa-lg" aria-hidden="true"></i>
</form>
</div>
</div>
</div>
</div>
CSS
*:focus {
outline: none;
}
body {
background-color: #F1F1FA;
font-family: sans-serif;
margin: 0;
padding: 0;
}
.wrapper {
height: 100vh;
}
.top-bar {
display: flex;
position: absolute;
left: 17%;
width: 83%;
height: 50px;
background-color: white;
box-shadow: 0 2px 4px 0 rgba(0,0,0,0.10);
}
.search-input {
align-self: center;
margin-left: 10px;
}
.search-input form input[type="text"] {
padding: 5px;
}
input[type="button"] {
border: none;
background-color: Transparent;
outline: none;
height: 20px;
width: 92%;
font-size: 13px;
font-weight: regular;
color: #B9B9B9;
text-align: left;
}
.side-bar {
display: flex;
flex-direction: column;
width: 17%;
height: 100%;
background-color: #272C32;
}
.sub-title {
margin-top: 4%;
margin-left: 7.5%;
}
.sub-title h3 {
color: #B9B9B9;
font-size: 13px;
font-weight: lighter;
}
.splitter {
display: flex;
align-self: center;
width: 85%;
min-height: 0.5px;
background-color: grey;
margin-top: 0px;
margin-bottom: 4%;
}
.button {
position: relative;
margin-left: 7.5%;
margin-bottom: 5%;
}
.button-container {
margin-left: 30px;
}
.button form i {
color: white;
font-size: 14px;
transition: 0.3s;
position: absolute;
left: 0px;
top: 0px;
padding: 5px 0px;
}
.button input:hover+i {
color: dodgerblue;
}
答案 0 :(得分:1)
如果需要窗口的高度,请使用100vh
。
还用<h3>
关闭您的</h3>
标签
答案 1 :(得分:1)
现在检查一下
只有我将overflow: auto
添加到您的.side-bar
容器中
*:focus {
outline: none;
}
body {
background-color: #F1F1FA;
font-family: sans-serif;
margin: 0;
padding: 0;
}
.wrapper {
height: 100vh;
}
.top-bar {
display: flex;
position: absolute;
left: 17%;
width: 83%;
height: 50px;
background-color: white;
box-shadow: 0 2px 4px 0 rgba(0,0,0,0.10);
}
.search-input {
align-self: center;
margin-left: 10px;
}
.search-input form input[type="text"] {
padding: 5px;
}
input[type="button"] {
border: none;
background-color: Transparent;
outline: none;
height: 20px;
width: 92%;
font-size: 13px;
font-weight: regular;
color: #B9B9B9;
text-align: left;
}
.side-bar {
display: flex;
flex-direction: column;
width: 17%;
height: 100%;
background-color: #272C32;
overflow: auto
}
.sub-title {
margin-top: 4%;
margin-left: 7.5%;
}
.sub-title h3 {
color: #B9B9B9;
font-size: 13px;
font-weight: lighter;
}
.splitter {
display: flex;
align-self: center;
width: 85%;
min-height: 0.5px;
background-color: grey;
margin-top: 0px;
margin-bottom: 4%;
}
.button {
position: relative;
margin-left: 7.5%;
margin-bottom: 5%;
}
.button-container {
margin-left: 30px;
}
.button form i {
color: white;
font-size: 14px;
transition: 0.3s;
position: absolute;
left: 0px;
top: 0px;
padding: 5px 0px;
}
.button input:hover+i {
color: dodgerblue;
}
<div class="wrapper">
<div class="top-bar">
<div class="search-input">
<form>
<div class="input-field">
<input type="text" placeholder="Search user" name="userPost">
</div>
</form>
</div>
</div>
<div class="side-bar">
<div class="sub-title">
<h3>ADMIN TOOLS<h3>
</div>
<div class="splitter"></div>
<div class="button">
<div class="button-container">
<form>
<input type="button" value="Dashboard" onclick="window.location.href='http://www.google.com'"/>
<i class="fas fa-tachometer-alt fa-lg" aria-hidden="true"></i>
</form>
</div>
</div>
<div class="button">
<div class="button-container">
<form>
<input type="button" value="Ban Panel" onclick="window.location.href='http://www.google.com'"/>
<i class="fas fa-ban fa-lg" aria-hidden="true"></i>
</form>
</div>
</div>
<div class="button">
<div class="button-container">
<form>
<input type="button" value="Warn Panel" onclick="window.location.href='http://www.google.com'"/>
<i class="fas fa-exclamation-circle fa-lg" aria-hidden="true"></i>
</form>
</div>
</div>
<div class="button">
<div class="button-container">
<form>
<input type="button" value="Gift Panel" onclick="window.location.href='http://www.google.com'"/>
<i class="fas fa-gift fa-lg" aria-hidden="true"></i>
</form>
</div>
</div>
<div class="button">
<div class="button-container">
<form>
<input type="button" value="User Info" onclick="window.location.href='http://www.google.com'"/>
<i class="fas fa-user fa-lg" aria-hidden="true"></i>
</form>
</div>
</div>
<div class="sub-title">
<h3>NEWS TOOLS<h3>
</div>
<div class="splitter"></div>
<div class="button">
<div class="button-container">
<form>
<input type="button" value="New Post" onclick="window.location.href='http://www.google.com'"/>
<i class="fas fa-file fa-lg" aria-hidden="true"></i>
</form>
</div>
</div>
<div class="button">
<div class="button-container">
<form>
<input type="button" value="Remove Post" onclick="window.location.href='http://www.google.com'"/>
<i class="fas fa-trash fa-lg" aria-hidden="true"></i>
</form>
</div>
</div>
<div class="sub-title">
<h3>OTHER<h3>
</div>
<div class="splitter"></div>
<div class="button">
<div class="button-container">
<form>
<input type="button" value="Game Statistics" onclick="window.location.href='http://www.google.com'"/>
<i class="fas fa-chart-line fa-lg" aria-hidden="true"></i>
</form>
</div>
</div>
</div>
</div>