html - Background image not covering entire page? -
i've begun learning html , css (and little bootstrap) , i'm trying make simple scrolling webpage. problem cannot div background image cover full height of page -- covers far h2 text, thinks end of element end of page. have no idea why it's doing , haven't been able fix it. has stumped me , i'm sure has simple solution i've missed. advice hugely appreciated.
here codepen:
body { background-color: rgb(255, 255, 255); } #front { background: url("https://image.ibb.co/mjtmwv/port34.png") no-repeat; overflow: hidden; background-size: cover; width: 100%; height: 100%; } #h1 { color: white; font-size: 50px; margin-top: 40vh; padding: 10px; background: rgba(43, 142, 255, 0.4); } #pt { color: white; font-size: 30px; background: rgba(39, 220, 130, 0.4); } <ul style="z-index:9;"> <li> <a class="active" href="#"><img class="img-fluid" style="width:auto;height:auto;max-height:26px;max-width:20px;" src="https://image.ibb.co/mg1s3a/lyreimage27.png" alt="website icon"></img> placeholder inc.</a> </li> <li><a href="#">about </a> </li> <li><a style="text-decoration:none" href="#">portfolio</a> </li> <li><a href="#">contact</a> </li> </ul> <header> <div id="front"> <div class="container-fluid"> <h1 id="h1" class="text-center">placeholder</h1> <h2 id="pt" class="text-center">placeholder text</h2> </header>
i cleaned markup little bit (try not use inline styles when possible) , think achieved effect looking for.
#front { background: url("https://image.ibb.co/mjtmwv/port34.png") no-repeat; overflow: hidden; background-size: cover; width: 100%; min-height: 100vh; } .text-center { text-align: center; } h1 { color: white; font-size: 50px; margin-top: 40vh; padding: 10px; background: rgba(43, 142, 255, 0.4); } h2 { color: white; font-size: 30px; background: rgba(39, 220, 130, 0.4); } ul { list-style-type: none; margin: 0; padding: 0; overflow: hidden; background-color: rgba(0, 0, 0, 0.7); position: fixed; top: 0; width: 100%; font-size: 16px; z-index: 9; } li { float: left; } li { display: block; color: white; text-align: center; padding: 14px 16px; text-decoration: none; } li a:hover:not(.active) { color: white; background-color: rgba(39, 220, 130, 0.4); transition: 0.5s; text-decoration: none; } .active { color: white; background-color: rgba(43, 142, 255, 0.4); } .active:hover { color: white; text-decoration: none; } .active img { width:auto; height:auto; max-height:26px; max-width:20px; } <ul> <li><a class="active" href="#"><img class="img-fluid" src="https://image.ibb.co/mg1s3a/lyreimage27.png" alt="website icon" />placeholder inc.</a></li> <li><a href="#">about</a></li> <li><a href="#">portfolio</a></li> <li><a href="#">contact</a> </li> </ul> <header id="front"> <div> <div class="container-fluid text-center"> <h1>placeholder</h1> <h2>placeholder text</h2> </div> </div> </header>
Comments
Post a Comment