I've built a website using Bootstrap, but I'm facing issues with setting the main content area. Even though I've specified height in percentages and set a min-height, the location of the div shifts when I navigate between pages using jQuery load().
Below is the code for my main page:
$(document).ready(function() {
$(".content").load("defaultcontent.html");
$(".about").click(function(e) {
$(".content").load("about.html");
});
$(".home").click(function(e) {
$(".content").load("defaultcontent.html");
});
$(".products").click(function(e) {
$(".content").load("products.html");
});
$(".contact").click(function(e) {
$(".content").load("contactus.html");
});
});
body {
background-image:
url("https://www.airmanchallenge.com/images/backgroundSite.jpg");
color: white;
}
.navbar>a:hover {
background-color: black;
color: white;
}
.topnav >a:hover {
background-color: black;
color: white;
}
.content {
height: auto;
min-height: 400px;
}
<!DOCTYPE html>
<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Sample Page</title>
<link
href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"
rel="stylesheet" type="text/css" />
<script type="text/javascript"
src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
<script type="text/javascript"
src="https://code.jquery.com/ui/1.12.1/jquery-ui.min.js"></script>
<script type="text/javascript"
src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>
<header class="text-center">
<h1>ABC Store</h1>
<p>some description</p>
</header>
<nav role="navigation" class="navbar navbar-default">
<!-- Collection of nav links and other content for toggling -->
<div id="navbarCollapse" class="collapse navbar-collapse">
<ul class="nav navbar-nav topnav">
<li><a class="home">Home</a></li>
<li><a class="products">Products</a></li>
<li><a class="contact">Contact</a></li>
<li><a class="about">About</a></li>
</ul>
</div>
</nav>
<div class="container">
<div class="row">
<span>
<div class="row-sm-12 row-md-12 row-lg-12 content"
style="background-color: lightblue;"></div>
</span>
</div>
</div>
<footer class="text-center"> © ABC Group. All Rights
Reserved </footer>
</body>
</html>
Any ideas on how to resolve this issue? I'm unsure about what's causing it.
You can visit the hosted website to see the problem firsthand.