我想将div放在其他div的下面。而不是被放置在彼此之下他们覆盖。将div放在彼此之下
页面外观概述: 我使用引导来设计它。我正在使用中间带有品牌徽标的固定导航栏。在导航栏下方放置了一张图片。
很好的导航栏和图像堆栈的div,但是当我尝试在图像下面添加另一个div时,它会覆盖图像,并且不在图像下方的导航栏下方。
理想情况下,我想将navbar和图像div放在容器中,但我没有试图这么做。
的Index.html
<!DOCTYPE html>
<html>
<head>
<title>welcome</title>
<!-- Bootstrap -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<!-- AnjularJs -->
<script src="js/angular.min.js"></script>
<!-- css files -->
<link rel="stylesheet" href="navBar.css">
</head>
<body>
<!-- Navigation Bar -->
<div class="navbar navbar-default navbar-fixed-top">
<div class="container-fluid">
<a class="navbar-brand">Name</a>
</div>
</div>
<!-- End of Navigation Bar -->
<div class="arrow"></div>
<!--Image-->
<div class=bkgimage><h1>Slogan</h1></div>
<!--End of image -->
<!-- Want to add another div here -->
</body>
</html>
navBar.css
body {
padding:0px;
margin:0px;
}
.navbar-brand {
display:inline-block;
float:none;
color:white;
font-family: Arial, Helvetica, sans-serif;
font-style:italic;
font-size: 50px;
font-weight: bold;
font-variant: small-caps;
}
.navbar {
position:relative;
margin: 0px;
padding:10px;
text-align:center;
background-color: #00b3b3;
border:none;
}
.arrow {
position:absolute;
left:50%;
margin-left: -20px;
width:0;
height:0;
border-left:20px solid transparent;
border-right:20px solid transparent;
border-top: 20px solid #00b3b3;
z-index:2;
}
.navbar-default .navbar-brand {
color:white;
}
.navbar-default .navbar-brand:focus, .navbar-default .navbar-brand:hover {
color:white;
}
.bkgimage {
position: absolute;
background-image: url('test.jpg');
background-position: center;
background-repeat: no-repeat;
background-size: cover;
width:100%;
height:75%;
}
.bkgimage h1 {
color: white;
font-family: Arial, Helvetica, sans-serif;
font-style:italic;
font-size: 40px;
font-weight: bold;
font-variant: small-caps;
text-align: center;
margin-top: 150px;
}
当您添加position:absolute;任何事情,你从页面的自然流程中删除它,所以下一个项目不会轻易跟随它 –