For a project I started making a template containing a banner (80% of the page).
Yesterday I had a problem with using %
. %
wasn't working for me while vh
did. The problem, someone said, was that the div where I had put the background was also in a div but without a height. So I defined that to 100%
. But still it doesn't work. The background-image
is just as big as the content of the div itself.
My codes:
@charset "utf-8";
/* CSS Document */
/*MAIN*/
body{
width: 100%;
height: 100%;
}
/*BANNER*/
#banner{
width: 100%;
height: 100%;
background-color: black;
}
#bannerimg{
background-image: url("https://www.gettyimages.ie/gi-resources/images/Homepage/Hero/UK/CMS_Creative_164657191_Kingfisher.jpg");
background-repeat: no-repeat;
background-attachment: fixed;
background-position: center;
height: 80%;
}
<!DOCTYPE html>
<html>
<head>
<!--ALGEMEEN-->
<meta charset="utf-8">
<title>Homepagina - RC paneel</title>
<!--FONT-->
<!--INCLUDE-->
<link href="//cdn.muicss.com/mui-0.9.41/css/mui.min.css" rel="stylesheet" type="text/css" />
<script src="//cdn.muicss.com/mui-0.9.41/js/mui.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script><script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>
<!--STYLE-->
<link rel="stylesheet" href="css/index.css">
<!--SCRIPT-->
</head>
<body>
<!--BANNER-->
<section id="banner">
<!--NAVBAR-->
<!--BANNER-->
<div id="bannerimg">
Test
</div>
</section>
<!--OVER ONS-->
<!--VEELGESTELDE VRAGEN-->
<!--CONTACT-->
</body>
</html>