这是我的代码,HTML和body具有body类,然后在其中有一个div具有背景图像,在其中有一个div具有颜色覆盖层,最后在其中有一个登录表单。我已在页面中滚动,如何删除它并且有一个页面没有滚动。对于我来说,重要的是要确保所有介质尺寸均正确。
.bg-image{
background: url("../images/666664.jpg") ;
height: 100%;
position: relative;
background-position: center;
background-repeat: no-repeat;
background-size: cover;
}
.body{
height: 100%;
margin: 0;
font: 400 15px/1.8 "Lato", sans-serif;
color: white!important;
}
.color-overlay {
position: relative;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: #0d235b;
opacity: 0.6;
}
<html class="body">
<head>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
</head>
<body class="body">
<div class="bg-image">
<div class="color-overlay"></div>
<div class="container">
<div class="row">
<form class="login form_height col-xs-12 ">
<div class="form-group row">
<label for="staticEmail" class="col-sm-3 col-form-label">Username</label>
<div class="col-sm-9">
<input placeholder="Username" type="text" class="form-control" id="staticEmail">
</div>
</div>
<div class="form-group row">
<label for="inputPassword" class="col-sm-3 col-form-label">Password</label>
<div class="col-sm-9">
<input type="password" class="form-control" id="inputPassword" placeholder="Password">
</div>
</div>
<div class="form-group row">
<label for="sub_btn" class="col-sm-3 col-form-label" ></label>
<div class="col-sm-9">
<input type="submit" class="btn login_btn btn-default btn_sub " value="Login" id="sub_btn" >
</div>
</div>
</form>
</div>
</div>
</div>
<footer class="col-xs-12 no-padd"></footer>
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous"></script>
</body>
</html>
答案 0 :(得分:0)
我的猜测是,由于<div class="container">
<div class="row no-gutters justify-content-center">
<div class="col-sm-4">
<img src="https://via.placeholder.com/400X400" class="img-fluid">
</div>
<div class="col-sm-4 text-center bg-dark text-white align-self-center">
<h4>Awesome desk</h4>
</div>
</div>
</div>
/ form
在.container
div之外,因此无法正常工作。
.color-overlay
.bg-image{
background: url("../images/666664.jpg") red;
height: 100%;
position: relative;
background-position: center;
background-repeat: no-repeat;
background-size: cover;
}
.body{
height: 100%;
margin: 0;
font: 400 15px/1.8 "Lato", sans-serif;
color: white!important;
}
.color-overlay {
position: relative;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: #0d235b;
opacity: 0.6;
}
答案 1 :(得分:0)
您需要将<div class="container">...</div>
放在<div class="color-overlay"></div>
内-必须解决您的问题。