Reputation: 5
I am a beginner in bootstrap and I have been experimenting with it to create a homepage for my website. The problem I am facing is this:
The three images are overlapping the jumbotron and I can't figure out why. The following is the HTML code:
<!--navigation bar-->
<div class="navbar-wrapper">
<nav class="navbar navbar-inverse navbar-static-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<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="logo" href="#"><img src="C:\Users\Mickey.Utopia\Documents\EdHoc\temp-logo.jpg" height= "50" width = "80"></a>
</div>
<div class="navbar-collapse collapse navbar-right">
<ul class="nav navbar-nav">
<!--
<li class="active"><a href="#">Home</a></li>
-->
<li class = "animate"><a href="#about">About</a></li>
<li><a href="#contact">Contact</a></li>
<li><a href = "C:\Users\Mickey.Utopia\Documents\EdHoc\Sign_in.htm">Sign In</a></li>
<li><a href = "#">Sign Up</a></li>
</ul>
</div>
</div>
</nav>
</div>
<div class='jumbotron' >
<div class="container">
<div class="row">
<div class="col-xs-12 col-lg-12 col-sm-12" >
<h1 id="jumb">Welcome to EdHoc. <br>Discover the best places to learn and collaborate with friends to make learning easier.</h1>
</div>
<div class="row">
<div class="col-xs-8 col-lg-8 col-sm-8" id="search">
<!--Search Bar here-->
<input type="text" class="form-control" placeholder="Search by location, institute, discipline" id="srcb">
<!--Button-->
</div>
<div class="col-xs-4 col-lg-4 col-sm-4" id="button">
<a href="" class="btn btn-default">Go</a>
</div>
</div>
</div>
</div>
</div>
<hr>
<div class="container marketing">
<!-- Three columns of text below the jumbotron -->
<div class="row">
<div class="col-sm-8 col-xs-12 col-lg-4">
<img class="img-circle" src="data:image/gif;base64,R0lGODlhAQABAIAAAHd3dwAAACH5BAAAAAAALAAAAAABAAEAAAICRAEAOw==" alt="Generic placeholder image" width="140" height="140">
<h2>Heading</h2>
<p>Donec sed odio dui. Etiam porta sem malesuada magna mollis euismod. Nullam id dolor id nibh ultricies vehicula ut id elit. Morbi leo risus, porta ac consectetur ac, vestibulum at eros. Praesent commodo cursus magna.</p>
<p><a class="btn btn-default" href="#" role="button">View details »</a></p>
</div><!-- /.col-lg-4 -->
<div class="col-lg-4">
<img class="img-circle" src="data:image/gif;base64,R0lGODlhAQABAIAAAHd3dwAAACH5BAAAAAAALAAAAAABAAEAAAICRAEAOw==" alt="Generic placeholder image" width="140" height="140">
<h2>Heading</h2>
<p>Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit. Cras mattis consectetur purus sit amet fermentum. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh.</p>
<p><a class="btn btn-default" href="#" role="button">View details »</a></p>
</div><!-- /.col-lg-4 -->
<div class="col-lg-4">
<img class="img-circle" src="data:image/gif;base64,R0lGODlhAQABAIAAAHd3dwAAACH5BAAAAAAALAAAAAABAAEAAAICRAEAOw==" alt="Generic placeholder image" width="140" height="140">
<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 justo sit amet risus.</p>
<p><a class="btn btn-default" href="#" role="button">View details »</a></p>
</div><!-- /.col-lg-4 -->
</div><!-- /.row -->
<!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="\bootstrap-3.3.5-dist\bootstrap-3.3.5-dist\js\bootstrap.min.js"></script>
<!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
<script src="../../assets/js/ie10-viewport-bug-workaround.js"></script>
The related CSS (apart from the bootstrap files):
.navbar {
background-color: transparent;
border: none;
}
.jumbotron {
height: 400px;
background-image: url(../images/woman.jpg);
background-size: cover;
border: none;
width: 100%;
position: absolute;
top:0;
z-index: -100;
}
#jumb {
color: white;
font-size: 20px;
}
How can I fix this?
Upvotes: 0
Views: 2319
Reputation: 21663
You have your jumbotron
div using position:absolute which is why the content under it is overlapping. See the following references:
position: absolute; An element with position: absolute; is positioned relative to the nearest positioned ancestor (instead of positioned relative to the viewport, like fixed).
However; if an absolute positioned element has no positioned ancestors, it uses the document body, and moves along with page scrolling.
Note: A "positioned" element is one whose position is anything except static.
And
Overlapping Elements When elements are positioned, they can overlap other elements.
The z-index property specifies the stack order of an element (which element should be placed in front of, or behind, the others).
An element can have a positive or negative stack order:
Absolute, Relative, Fixed Positioning: How Do They Differ?
*You also have some structural inconsistencies such as col-sm-8 col-xs-12 col-lg-4
This makes little sense to place the smallest breakpoint size between to larger sizes: See Grid
You should start by consulting the documentation as to how these components are structured and how they interact with one another. Docs
.navbar.navbar-custom {
background: none;
border: none;
margin-bottom: -50px;
}
div.jumbotron {
height: 400px;
background-image: url(http://interiorofficesystems.com/wp-content/themes/ios/uploads/product_photo/afe3a3ed124cb421preview%20-%20114371%20-%20Tayco_View02.jpg);
background-size: cover;
border: none;
}
div.jumbotron .jumb {
margin-bottom: 20px;
color: white;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" />
<nav class="navbar navbar-inverse navbar-static-top navbar-custom">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar"> <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="logo" href="#">
<img src="http://placehold.it/80x50/266080/fff" height="50" width="80">
</a>
</div>
<div class="collapse navbar-collapse" id="navbar">
<ul class="nav navbar-nav navbar-right">
<li class="animate"><a href="#about">About</a>
</li>
<li><a href="#contact">Contact</a>
</li>
<li><a href="C:\Users\Mickey.Utopia\Documents\EdHoc\Sign_in.htm">Sign In</a>
</li>
<li><a href="#">Sign Up</a>
</li>
</ul>
</div>
</div>
</nav>
<div class='jumbotron'>
<div class="container">
<div class="jumb">
<h1>Welcome to EdHoc.</h1>
<br>
<p>Discover the best places to learn and collaborate with friends to make learning easier.</p>
</div>
<div class="input-group input-group-lg">
<input type="text" id="search" class="form-control" placeholder="Search by location, institute, discipline" id="srcb"> <span class="input-group-btn">
<button class="btn btn-default btn-lg" id="button" type="button">Go!</button>
</span>
</div>
</div>
</div>
<div class="container text-center">
<div class="row">
<div class="col-sm-4">
<img class="img-circle" src="http://placehold.it/200x200/000" alt="Generic placeholder image" width="140" height="140">
<h2>Heading</h2>
<p>Donec sed odio dui. Etiam porta sem malesuada magna mollis euismod. Nullam id dolor id nibh ultricies vehicula ut id elit. Morbi leo risus, porta ac consectetur ac, vestibulum at eros. Praesent commodo cursus magna.</p> <a class="btn btn-default"
href="#" role="button">View details »</a>
</div>
<div class="col-sm-4">
<img class="img-circle" src="http://placehold.it/200x200/000" alt="Generic placeholder image" width="140" height="140">
<h2>Heading</h2>
<p>Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit. Cras mattis consectetur purus sit amet fermentum. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh.</p> <a class="btn btn-default"
href="#" role="button">View details »</a>
</div>
<div class="col-sm-4">
<img class="img-circle" src="http://placehold.it/200x200/000" alt="Generic placeholder image" width="140" height="140">
<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 justo sit amet risus.</p>
<a
class="btn btn-default" href="#" role="button">View details »</a>
</div>
</div>
</div>
Upvotes: 1