Fins Up
Fins Up

Reputation: 39

Background image won't fill the screen

I have been setting up my webpage for a couple of weeks now. Just today I decided to take my navbar section and meta tags and links, and put them over on the master page. When I did this, everything went smoothly except for one thing. The top info section background is cut off short on the bottom. It is almost like its not reading the height: 100% in my style sheet. Here is my master page that I moved some stuff over to.

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    @rendersection("prehead",false)

    <title>
        @viewdata("title")
    </title>

    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
    <link href="//fonts.googleapis.com/css?family=Roboto:100,400,400i,700" rel="stylesheet">
    <link rel="stylesheet" href="~/CMS_Static/CSS/floridaVisionsStyles.css">

  </head>
  <body>

    <nav class="navbar navbar-default top-of-page">
  <div class="container">
    <!-- Brand and toggle get grouped for better mobile display -->
    <div class="navbar-header">
      <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
        <span class="sr-only">Toggle navigation</span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </button>
      <a class="navbar-brand" href="#"><img src='/CMS_Static/Uploads/313864614C6F6F/fv-logo-3.gif' align="left"/></a>
    </div>

    <!-- Collect the nav links, forms, and other content for toggling -->
    <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
      <ul id="navLinks" class="nav navbar-nav">
        <li><a href="#">Home</a></li>
        <li><a href="#">Services</a></li>
        <li><a href="#">Locations</a></li>
        <li><a href="#">Prices</a></li>
        <li><a href="#">Contact</a></li>
      </ul>
    </div>
  </div>
</nav>

@renderbody()

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
    <script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>    

  <script>  $(window).on("scroll", function() {
    var scrollPos = $(window).scrollTop();
    if (scrollPos <= 0) {
        $('.navbar-default').addClass('top-of-page');
    } else {
        $('.navbar-default').removeClass('top-of-page');
    }
});
   </script>
   @renderSection("scripts",false)
  </body>
</html>

Here is my top info section with the cut off Background

<section class="topInfo">
    <div class="container">
        <div class="row">
            <div class="col-md-10 col-md-offset-1">
                <h1 class="topInfoText text-center">Aerial Drone Services, Stock Footage, and Affordable Prints</h1>
            </div>
            <div class="col-sm-4 col-sm-offset-4">
                 <a class="btn bannerBtn btn-block" href="#">Learn More</a>
            </div>
        </div>
    </div>
</section>

and the style for the topInfo class

.topInfo {
        background-image: linear-gradient( rgba(0,0,0,.25), rgba(0,0,0,.25) ), url('/CMS_Static/Uploads/313864614C6F6F/exuma rocks 2.jpg');
        background-attachment: fixed;
        background-size: cover;
        background-repeat: no-repeat;
        background-position: center;
        height: 100%;
    }

Upvotes: 1

Views: 1140

Answers (1)

webdevdani
webdevdani

Reputation: 1102

An element with height: 100% can only ever be as tall as it's parent. How tall is the parent? If it's a direct child of the body, try setting this in your CSS:

html, body {
   height: 100%;
}

Upvotes: 4

Related Questions