我写了几页的简单网站
我的html中有这个代码。它在正常分辨率下工作正常
body {
background-image: url(../image/BKG.jpg);
background-position: center top;
background-repeat: no-repeat;
color: #ffffff;
height: 100%;
width: 100%;
font-family: 'TimesNewRoman';
}
* {
border: 1px solid red;
}
.navbar {
border-radius: 0;
border: none;
min-height: 130px;
}
.navbar-default {
background: none;
color: none;
}
.navbar-header {
margin-top: 10px;
}
.navbar-brand {
height: 100%;
}
.navbar-brand img {
display: block;
}
.navbar-nav {
margin-top: 64px;
}
.navbar-nav>li {
font-size: 26px;
}
.navbar-default .navbar-nav>li>a {
padding: 20px 38px;
color: #ffffff;
position: relative;
display: inline-block;
}
.navbar-nav>li>a:hover::after,
.navbar-nav>li>a.active::after {
content: '';
position: absolute;
top: 31px;
left: -10px;
background-image: url(../image/Arrow_left.png);
background-size: 100%;
width: 44px;
height: 3px;
}
.navbar-nav>li>a:hover::before,
.navbar-nav>li>a.active::before {
content: '';
position: absolute;
top: 31px;
right: -10px;
background-image: url(../image/Arrow_right.png);
background-size: 100%;
width: 44px;
height: 3px;
}
.navbar-default .navbar-nav>li>a:hover,
.navbar-default .navbar-nav>li>a:link {
color: #ffffff;
}
.navbar-default .navbar-toggle:focus,
.navbar-default .navbar-toggle:hover {
background-color: #ffffff;
}
.navbar-default .navbar-toggle {
border-color: #ffffff;
}
.container.text {
text-align: center;
background-color: rgba(0, 0, 0, 0.3);
font-size: 28px;
line-height: 32px;
padding: 70px 9% 50px;
margin-top: 9%;
}
.container.text img {
margin-right: 20px;
}
.container.text p {
margin-bottom: 20px;
}
.container.text.contacts p {
margin-bottom: 77px;
}
.container.text.disclaimer {
padding: 15px 50px;
}
.container-fluid.footer {
box-shadow: 0 -40px 40px -20px black inset;
padding: 10px 0;
}
.container.footer {
text-align: center;
font-size: 18px;
}
.container.footer a:hover {
color: #ffffff;
text-decoration: underline;
}
@media (max-width: 767px) {
body {
background-size: cover;
}
.navbar-brand {
width: 80%;
}
.navbar-toggle {
margin-top: 11%;
}
}
.fix {
position: absolute;
width: 100%;
bottom: 0;
}
<body>
<nav class="navbar navbar-default">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#"><img class="img-responsive" src="image/Logo_cutted.png" alt="logo" /></a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav navbar-right">
<li><a href="contact_us.html">Contact Us</a></li>
<li><a href="http://crescentcovecapital.fileshare.com" target="_blank">Investor Login</a></li>
<li><a href="about_us.html">About Us</a></li>
</ul>
</div>
<!-- /.navbar-collapse -->
</div>
<!-- /.container-fluid -->
</nav>
<!-- /.navbar navbar-default -->
<footer style="height:auto;" class="container-fluid footer">
<div class="row">
<div class="container footer">
Copyright © 2017 Crescent Cove. All Rights reserved. <a href="#">Disclaimer</a>
</div>
</div>
</footer>
它运作正常,但是当我最小化窗口时,我在页面底部有空白区域
我该如何解决?
感谢您的帮助。
答案 0 :(得分:1)
更新css部分
body {
background-image: url(../image/BKG.jpg);
background-position: center top;
background-repeat: no-repeat;
color: #ffffff;
height: 100vh; /* Add this */
width: 100%;
font-family: 'TimesNewRoman';
}
答案 1 :(得分:0)
将此添加到您的身体:
body{
background: url(YOURIMG.jpg) no-repeat center center fixed;
background-position: center center;
}