You can’t nest containers in bootstrap because they supply padding that is immediately offset in rows and columns to create the grid gutters. If you want a full width (viewport edge to edge) layout then just use your own div with appropriate class outside of a bootstrap container.
In your new example you would need to add these two new elements and move the styling to them instead of the ones you had. Here’s a fully working example.
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
<style>
header.header-blue {
z-index: 1000;
position: -webkit-sticky;
position: sticky;
top: 0
}
.top-wrap {
background: #064882;
background: linear-gradient(-45deg, #064882, #00284c, #064882, #00284c);
background-size: 300% 300%;
-webkit-animation: Gradient 8s ease infinite;
-moz-animation: Gradient 8s ease infinite;
animation: Gradient 8s ease infinite;
color: #fff;
font-size: 18px;
box-shadow: 0 5px 8px 0 rgba(0, 0, 0, 0.2);
border-bottom: 1px solid #00111f;
}
.header-container {
padding: 15px 0;
}
.container-nav {
display: flex;
}
.container-nav>div {
margin-left: 30px;
}
.col-logo {
margin: 0 auto 0 0;
}
.col-menu, .col-ask-button, .col-search, .col-topics {
margin-left: 30px;
}
/* SEARCH */
#search-wrap {
position:absolute;
top:100%;
left:0;
right:0;
border-top: 1px solid #d8d8d8;
padding-left: 25px;
padding-right: 10px;
z-index: 9999;
background: #fff;
-webkit-box-shadow: -1px 2px 2px rgba(0, 0, 0, 0.2);
-moz-box-shadow: -1px 2px 2px rgba(0, 0, 0, 0.2);
box-shadow: -1px 2px 2px rgba(0, 0, 0, 0.2);
display: none;
}
#search-bar {
width: 100%;
}
#s {
display: block;
width: 88%;
border: 0;
outline: none;
padding: 0;
height: 60px;
line-height: 60px;
font-size: 3.0em;
font-weight: bold;
color: #676767;
}
#searchsubmit {
display: block;
float: right;
margin-top: 6px;
background: none;
color: #717171;
border: 0;
outline: none;
cursor: pointer;
}
/* end SEARCH */
</style>
</head>
<body>
<!-- main menu -->
<header class="header-blue">
<div class="top-wrap">
<div class="container">
<div class="row">
<div class="col-md-12">
<div class="container-nav header-container">
<div class="col-logo"> Logo </div>
<div class="col-topics"> Categories </div>
<div class="col-search"> <a href="#" id="searchtoggl">search</a> </div>
<div class="col-ask-button"> <a href="#" class="ask-button">Button</a> </div>
<div class="col-menu"> menu </div>
</div>
</div>
</div>
</div>
</div>
<!-- search -->
<div id="search-wrap">
<div class="container">
<div class="row">
<div class="col-md-12">
<div id="search-bar" class="clearfix">
<form id="searchform" method="get" action="searchpage.php">
<button type="submit" id="searchsubmit" class="fa fa-search fa-4x"></button>
<input type="search" name="s" id="s" placeholder="Keywords..." autocomplete="off">
</form>
</div>
</div>
</div>
</div>
</div>
<!-- end search -->
</header>
<div class="clearfix"></div>
<!-- end main menu -->
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<script src="http://code.jquery.com/jquery-latest.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.2.1/js/bootstrap.min.js"></script>
<script>
jQuery(function() {
var $searchlink = jQuery('#searchtoggl i');
var $searchbar = jQuery('#search-wrap');
jQuery('.col-search a').on('click', function(e) {
e.preventDefault();
if (jQuery(this).attr('id') == 'searchtoggl') {
if (!$searchbar.is(":visible")) {
// if invisible we switch the icon to appear collapsable
$searchlink.removeClass('fa-search').addClass('fa-search-minus');
} else {
// if visible we switch the icon to appear as a toggle
$searchlink.removeClass('fa-search-minus').addClass('fa-search');
}
$searchbar.slideToggle(300, function() {
// callback after search bar animation
});
}
});
jQuery('#searchform').submit(function(e) {
e.preventDefault(); // stop form submission
});
});
</script>
</body>
</html>
I am guessing that you wanted the search dropdown to be full width and also guessing that you wanted the dummy text below not to move out of the way when the dropdown opens. If you do want the text to move down when the dropdown opens then change the position:absolute to position:relative instead.
Note that your version does not close when clicked outside the page unlike the previous method I gave you. If you want to achieve that you would need to check for a click on the document and act accordingly as in the code I gave you before. A possible easier way to do this is when the search menu opens you also open another fixed positioned overlay that covers the whole screen but with a z-index lower than than the header portions and then detect a click on that element. The fixed element would be outside the html of everything else and thus a click will not bubble through everything, You seem to have some other js in places I will leave that for you to implement.
Also your dropdown is not as smooth as the css version but the js slideToggle is always choppy. I assumed you added a height to the search to make it smoother but that would break the responsiveness so avoid that at all times,
Here’s the old version with the css animation plus bootstrap added. Im not sure why you made the nav so complicated either?
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
<style>
/*HEADER */
header.header-blue {
z-index: 1000;
position: -webkit-sticky;
position: sticky;
top: 0
}
.top-wrap {
background: #064882;
background: linear-gradient(-45deg, #064882, #00284c, #064882, #00284c);
background-size: 300% 300%;
animation: Gradient 8s ease infinite;
color: #fff;
font-size: 18px;
box-shadow: 0 5px 8px 0 rgba(0, 0, 0, 0.2);
border-bottom: 1px solid #00111f;
z-index:99;
position:relative;
}
.container-nav {
position:relative;
padding: 15px 0;
display: flex;
flex-wrap: nowrap;
}
.container-nav > div{margin-left:30px;}
.container-nav > .col-logo {
margin: 0 auto 0 0;
}
.container-nav {
display: flex;
}
/* SEARCH */
.btn-search {
border: 0;
color: #fff;
background:transparent;
/*padding:10px 15px;*/
cursor: pointer;
transition: all .5s ease-out;
}
.btn-search:hover {
color: #ccc;
}
#search-wrap {
background: #fffcc4;
padding: 20px 15px;
overflow: hidden;
opacity:0;
position:absolute;
z-index:1;
left:-999em;
box-sizing:border-box;
width:100%;
top:100%;
transform:translateY(-100%);
transition:transform 1s ease, opacity 1s ease, top 0s ease 1s, left 0s ease 1s;
}
#search-wrap.open {
transform:translateY(0%);
opacity:1;
left:0;
transition:transform 1s ease, opacity 1s ease;
}
#search form {
text-align: center;
max-width: 600px;
margin: 0 auto;
}
#search input {
padding: 5px;
font-size: 1.2rem;
border-radius: 5px;
border: 2px solid #00585f;
width: 100%;
}
#search #submit {
padding: 7px 10px;
background: #ff3800;
border: 0;
color: #fffcc4;
text-transform: uppercase;
}
#search .left-side {
float: left;
width: 75%;
}
#search .right-side {
float: right;
width: 20%;
}
</style>
</head>
<body>
<header class="header-blue">
<div class="top-wrap">
<div class="container">
<div class="row">
<div class="col-md-12">
<div class="container-nav">
<div class="col-logo"> Logo </div>
<div class="col-topics"> Categories </div>
<div class="col-search">
<button id="btn-search" class="btn-search">Search <i class="fa fa-search"></i></button>
</div>
<div class="col-ask-button"> <a href="#">Button</a> </div>
<div class="col-menu"> menu </div>
</div>
</div>
</div>
</div>
</div>
<div id="search-wrap">
<div id="search" class="container">
<div class="row">
<div class="col-md-12">
<form>
<div class="left-side">
<input type="text">
</div>
<div class="right-side">
<input id="submit" type="submit" value="Submit">
</div>
</form>
</div>
</div>
</div>
<!--/search-->
</div>
</header>
<div class="container">
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
<p> text </p>
</div>
<script src="http://code.jquery.com/jquery-latest.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.2.1/js/bootstrap.min.js"></script>
<script>
$('html').on("click", function(event) {
if ( event.target.id === 'search-wrap' || $(event.target).parents('#search-wrap').length) {
return;
}
if ( event.target.id === 'btn-search') {
$('#search-wrap').toggleClass('open');
} else {
$('#search-wrap').removeClass('open');
}
});
</script>
</body>
</html>