user3732216
user3732216

Reputation: 1589

Jumbotron and Navigation

I'm trying to figure out how I can have the my navigation sit ontop of the jumobtron but still be constrained to have the container class. Also my h1 and I'm wanting to have my h1 and p inside my header to be inside the container as well but I want the jumbotron to be full across the width of the page. I do not have any styles of my own it is all from bootstrap.

<!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">
        <title>Me - Web Designer/Developer</title>
        <link href="css/bootstrap.min.css" rel="stylesheet">
        <link rel="stylesheet" type="text/css" href="css/style.css">
        <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
        <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
        <!--[if lt IE 9]>
            <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
            <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
       <![endif]-->
    </head>
   <body>

       <header class="jumbotron">

           <nav class="navbar navbar-default navbar-fixed-top">
               <ul class="nav navbar-nav navbar-right">
                   <li><a href="#">Home</a></li>
                   <li><a href="#services">Services</a></li>
                   <li><a href="#works">Works</a></li>
                   <li><a href="#about">About</a></li>
                   <li><a href="#contact">Contact</a></li>
               </ul>
          </nav>

          <h1>Me</h1><p class="lead">Web Developer</p>
        </header>

        <div class="container">

            <section id="services">
                <h2 class="text-center">Services</h2>
                <div class="row">
                    ....

Upvotes: 0

Views: 8850

Answers (2)

vanburen
vanburen

Reputation: 21663

Here's a basic example. Change your navbar to background: transparent, place a container inside the jumbotron and inside the navbar as well.

<header class="jumbotron">
  <div class="container">

    <nav class="navbar navbar-inverse navbar-fixed-top">
      <div class="container">

Working Example:

nav.navbar {
  background: transparent;
  border: 0;
}
@media (max-width: 767px) {
  nav.navbar .navbar-collapse {
    border: 0;
    box-shadow: none;
  }
}
header {
  background-image: url('http://www.100resilientcities.org/page/-/100rc/img/cities/cities-la_optimized.jpg');
  background-size: cover;
  background-position: center;
  height: 400px;
}
header.jumbotron h1 {
  padding-top: 100px;
}
header.jumbotron h1,
header.jumbotron p {
  color: white;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" />
<header class="jumbotron">
  <div class="container">

    <nav class="navbar navbar-inverse navbar-fixed-top">
      <div class="container">

        <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="#">Brand</a>
        </div>

        <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
          <ul class="nav navbar-nav navbar-right">
            <li><a href="#">Home</a>
            </li>
            <li><a href="#services">Services</a>
            </li>
            <li><a href="#works">Works</a>
            </li>
            <li><a href="#about">About</a>
            </li>
            <li><a href="#contact">Contact</a>
            </li>
          </ul>
        </div>

      </div>
    </nav>

    <h1>Me</h1>
    <p class="lead">Web Developer</p>

  </div>
</header>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>

Upvotes: 1

Vee
Vee

Reputation: 11

Jumbotron and Navbars are different things and shouldn't be put one inside the other. When you define the nav class to be navbar-fixed-top, your navigation is taken away from the normal flow of the page, so you'd want something like this:

    <nav class="navbar navbar-default navbar-fixed-top">
        <div class="container">
            <ul class="nav navbar-nav navbar-right">
                <li><a href="#">Home</a></li>
                <li><a href="#services">Services</a></li>
                <li><a href="#works">Works</a></li>
                <li><a href="#about">About</a></li>
                <li><a href="#contact">Contact</a></li>
            </ul>
        </div>
    </nav>

    <header class="jumbotron">
        <div class="container">
            <h1>Me</h1>
            <p class="lead">Web Developer</p>
        </div>
    </header>

I believe this should be enough for your needs. Please do tell if it's not.

Upvotes: 1

Related Questions