我有这个号召性用语页面,它在图像顶部有一个背景图像和一个背景色;但是,我无法使背景颜色占据整个屏幕。在这里帮助不大!谢谢PS:我也在使用bootstrap cdns。链接到页面:http://pctechtips.org/apps/conf/ css:
/*
full stack conf style
*/
body {
background-image: url("http://travelhdwallpapers.com/wp-content/uploads/2017/03/Chicago-Wallpaper-3.jpg");
background-size: cover;
position: relative;
z-index: -10;
}
.hero {
height: 100vh;
top: 0;
bottom: 0;
background-color: rgba(31, 34, 118, 0.5);
z-index: -5;
}
HTML
<!DOCTYPE html>
<html>
<head>
<title></title>
<!-- bootstrap cdns css,js,popper.js,jquery -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css" integrity="sha384-PsH8R72JQ3SOdhVi3uxftmaW6Vc51MKb0q5P2rRUpPvrszuE4W1povHYgTpBfshb" crossorigin="anonymous">
<link rel="stylesheet" href="css/style.css">
</head>
<!-- bg-info = background blue, text-center = text white -->
<body class="text-white">
<div class="hero">
<div class="container text-center">
<h1 class="display-1" style="margin-top:12rem">Full Stack Conf</h1>
<p class="lead mb-5">Comming Soon, a One-day Conference About All Things Javascript!</p>
</div>
<div class="container text-center">
<div class="row">
<div class="col-6 mx-auto">
<div class="input-group">
<input type="text" class="form-control" placeholder="Recipient's username" aria-label="Recipient's username" aria-describedby="basic-addon2">
<span class="input-group-btn">
<button class="btn btn-primary" type="button">Sign up</button>
</span>
</div>
</div>
</div>
</div>
</div>
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.3/umd/popper.min.js" integrity="sha384-vFJXuSJphROIrBnz7yo7oB41mKfc8JzQZiCq4NCceLEaO4IHwicKwpJf9c9IpFgh" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/js/bootstrap.min.js" integrity="sha384-alpBpkh1PFOepccYVYDB4do5UnbKysX5WZXm3XxPqe5iKTfUKjNkCk9SaVuEZflJ" crossorigin="anonymous"></script>
</body>
</html>
好的,感谢上面评论过的人们的答案
/*
full stack conf style
*/
body {
background-image: url("http://travelhdwallpapers.com/wp-content/uploads/2017/03/Chicago-Wallpaper-3.jpg");
background-size: cover;
position: relative;
z-index: -10;
}
.hero {
position: absolute;
height: 100vh;
width: 100%;
top: 0;
bottom: 0;
background-color: rgba(31, 34, 118, 0.5);
z-index: -5;
}