Solved

Bootstrap background question

Posted on 2015-02-13
3
96 Views
Last Modified: 2016-02-25
I'm playing around with Bootstrap and I'm trying to figure out how to continue the background on a row the full width of the screen when it's inside a container that's not full width.  Specifically, the NAV has a blue background - but there is a considerable margin on the left and right side of the nav that is white.

Here's my code:

<!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">
    <meta name="description" content="">
    <meta name="author" content="">

    <title>Justified Nav Template for Bootstrap</title>

    <!-- Bootstrap core CSS -->
    <link href="css/bootstrap.css" rel="stylesheet">

    <!-- Custom styles for this template -->
    <link href="css/justified-nav.css" rel="stylesheet">

    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!--[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]-->
<!-- theme.css is empty right now... -->    
<link rel="stylesheet" type="text/css" href="css/theme.css">
  </head>

  <body>
<div class="row" style="margin-top:0px; padding-top:0px; min-height:100px; background-color:#000000;">
      	<div class="col-md-12" style="color:#ffffff;"><img src="images/logos/logo.jpg"></div>
      </div>
    
	  <div class="row">
        <nav class="main_nav">
          <ul class="nav nav-justified">
            <li class="active"><a href="#">home</a></li>
            <li><a href="#">categories</a></li>
            <li><a href="#">Link 2</a></li>
            <li><a href="#">Link 3</a></li>
            <li><a href="#">Link 4</a></li>
            <li><a href="#">Link 5</a></li>
            <li><a href="#">Link 6</a></li>
            <li><a href="#">Link 7</a></li>
            <li><a href="#">Link 8</a></li>
            <li><a href="#">Link 9</a></li>
          </ul>
        </nav>
      </div>
<div class="container">
      <!-- Jumbotron -->
      <div class="jumbotron">
        <h1>Marketing stuff!</h1>
        <p class="lead">Cras justo odio, dapibus ac facilisis in, egestas eget quam. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet.</p>
        <p><a class="btn btn-lg btn-success" href="#" role="button">Get started today</a></p>
      </div>

      <!-- Example row of columns -->
      <div class="row">
        <div class="col-lg-4">
          <h2>Safari bug warning!</h2>
          <p class="text-danger">As of v8.0, Safari exhibits a bug in which resizing your browser horizontally causes rendering errors in the justified nav that are cleared upon refreshing.</p>
          <p>Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui. </p>
          <p><a class="btn btn-primary" href="#" role="button">View details »</a></p>
        </div>
        <div class="col-lg-4">
          <h2>Heading</h2>
          <p>Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui. </p>
          <p><a class="btn btn-primary" href="#" role="button">View details »</a></p>
       </div>
        <div class="col-lg-4">
          <h2>Heading</h2>
          <p>Donec sed odio dui. Cras justo odio, dapibus ac facilisis in, egestas eget quam. Vestibulum id ligula porta felis euismod semper. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa.</p>
          <p><a class="btn btn-primary" href="#" role="button">View details »</a></p>
        </div>
      </div>

      <!-- Site footer -->
      <footer class="footer">
        <p>© Company 2014</p>
      </footer>

    </div> <!-- /container -->


    <!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
    <script src="../../assets/js/ie10-viewport-bug-workaround.js"></script>
  </body>
</html>

Open in new window


And here's the CSS for the Justified Nav template (justified-nav.css):
.footer {
  padding-top: 40px;
  padding-bottom: 40px;
  margin-top: 40px;
  border-top: 1px solid #eee;
}

/* Main marketing message and sign up button */
.jumbotron {
  text-align: center;
  background-color: transparent;
}
.jumbotron .btn {
  padding: 14px 24px;
  font-size: 21px;
}

/* Customize the nav-justified links to be fill the entire space of the .navbar */

.nav-justified {
  background-color: #0b74ee;
  border-radius: 0px;
}
.nav-justified > li > a {
  padding-top: 5px;
  padding-bottom: 5px;
  margin-bottom: 0;
  font-weight: bold;
  color: #FFF;
  text-align: center;
  background-color: #0b74ee; /* Old browsers */
  background-image: -webkit-gradient(linear, left top, left bottom, from(#0b74ee), to(#oe407d));
  background-image: -webkit-linear-gradient(top, #0b74ee 0%, #oe407d 100%);
  background-image:      -o-linear-gradient(top, #0b74ee 0%, #oe407d 100%);
  background-image: -webkit-gradient(linear, left top, left bottom, from(top), color-stop(0%, #0b74ee), to(#oe407d));
  background-image:         linear-gradient(top, #0b74ee 0%, #oe407d 100%);
  filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#0b74ee', endColorstr='#oe407d',GradientType=0 ); /* IE6-9 */
  background-repeat: repeat-x; /* Repeat the gradient */
  border-bottom: 1px solid #d5d5d5;
}

.nav-justified > .active > a,
.nav-justified > .active > a:hover,
.nav-justified > .active > a:focus {
  background-color: #0b74ee;
}
.nav-justified > li:first-child > a {
  border-radius: 0;
}
.nav-justified > li:last-child > a {
  border-bottom: 0;
  border-radius: 0;
}

ul.nav a:hover { background-color: #f13323 !important; }
.main_nav{
	width:1000px;
	margin-left:auto;
	margin-right:auto;	
}
@media (min-width: 768px) {
  .nav-justified {
    max-height: 25px;
  }
  .nav-justified > li > a {
    border-right: 1px solid #d5d5d5;
    border-left: 1px solid #fff;
  }
  .nav-justified > li:first-child > a {
    border-left: 0;
  }
  .nav-justified > li:last-child > a {
    border-right: 0;
  }
}

/* Responsive: Portrait tablets and up */
@media screen and (min-width: 768px) {
  /* Remove the padding we set earlier */
  .masthead,
  .marketing,
  .footer {
    padding-right: 0;
    padding-left: 0;
  }
}

Open in new window


Originally each of the rows is inside the container div.  - but because i want the background colors of the top two rows to go the width of the screen, I've taken them out of the container.

The problem is, I still want the content inside to be justified to the center of the screen.

Any suggestions?  Thanks for the help!!!
0
Comment
Question by:slightlyoff
  • 2
3 Comments
 
LVL 38

Accepted Solution

by:
Tom Beck earned 500 total points
ID: 40609729
You have already figured it out. Any section that you want full width goes outside the container div. The only thing that's keeping the menu from going full width is line 56 of justified-nav.css. Change the width from 1000px to 100%.
0
 
LVL 1

Author Comment

by:slightlyoff
ID: 40612349
Thanks Tom.

I think I was over thinking it.

I appreciate your help!!!
0
 
LVL 38

Expert Comment

by:Tom Beck
ID: 40612373
Gld to help. Thanks for the points.
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses how to create an extensible mechanism for linked drop downs.
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question