How to attach hanging div underneath Bootstrap 5 sticky nav - html

Using Bootstrap 5, I've got a sticky nav, which works as expected, but I need to display a hanging div (.chat-tag) directly underneath the sticky nav for a chat feature. This "hanging tag" should remain attached to the sticky nav when the user scrolls down the page.
It seems to display properly at widths of 992 and below, but for desktop, it appears in the same row as the top navigation.
Here's what I have so far, which I've also posted to Codepen:
https://codepen.io/Codewalker/pen/vYRoXdB?editors=1100
nav {
background-color: red;
height: 48px;
position: sticky;
top: 0;
}
.main-nav {
display: -webkit-flex;
display: inline-flex;
-webkit-justify-content: center;
}
.masthead-fluid {
background-color: #F7CAC9;
}
.masthead {
height: 60vh;
display: inline-flex;
align-items: center;
}
.chat-tag {
background-color: #B565A7;
display: flex;
align-items: center;
justify-content: center;
height: 50px;
width: 200px;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.0.2/css/bootstrap.min.css" rel="stylesheet" />
<header class="header sticky-top bg-white">
<div class="container-fluid">
<div class="nav-wrapper text-center">
<nav class="main-nav navbar navbar-expand-lg bg-white">
<div class="container-fluid text">
<a class="navbar-brand" href="#">
LOGO
</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="#what">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#registry">Page 1</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Page 2</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Page 3</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Page 4</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Page 5</a>
</li>
</ul>
</div>
</div>
<div class="chat-tag">Chat with us</div>
</nav>
</div>
</div>
</header>
<div class="container-fluid masthead-fluid mb-5">
<div class="row">
<div class="col-12">
<div class="color-overlay d-flex align-items-center">
<div class="container">
<div class="row">
<div class="col-12 masthead">
<h1>Hello, world!</h1>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="container">
<div class="row">
<div class="col-12">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Aliquam id diam maecenas ultricies mi eget mauris pharetra et. Non enim praesent elementum facilisis leo vel fringilla. Feugiat
scelerisque varius morbi enim. Ante metus dictum at tempor. Nec ultrices dui sapien eget mi proin. Accumsan lacus vel facilisis volutpat est velit egestas dui. Sit amet aliquam id diam. Vel fringilla est ullamcorper eget nulla. Malesuada fames
ac turpis egestas sed tempus urna. Lectus nulla at volutpat diam ut venenatis tellus. Et netus et malesuada fames ac turpis egestas integer. Amet nisl suscipit adipiscing bibendum est. Faucibus et molestie ac feugiat. Pretium nibh ipsum consequat
nisl vel pretium lectus. Vulputate mi sit amet mauris commodo quis imperdiet. A diam sollicitudin tempor id eu nisl. In egestas erat imperdiet sed euismod nisi. Aliquam malesuada bibendum arcu vitae elementum curabitur vitae. Nibh sit amet commodo
nulla facilisi nullam vehicula ipsum.</p>
<p>Malesuada fames ac turpis egestas maecenas pharetra convallis posuere morbi. Sit amet porttitor eget dolor morbi non arcu risus. Consectetur libero id faucibus nisl tincidunt eget nullam non. Sed risus ultricies tristique nulla aliquet. Tincidunt
arcu non sodales neque. Scelerisque eleifend donec pretium vulputate sapien nec sagittis. Scelerisque fermentum dui faucibus in ornare quam. Ullamcorper eget nulla facilisi etiam dignissim. Vel elit scelerisque mauris pellentesque pulvinar pellentesque
habitant. Magna fringilla urna porttitor rhoncus dolor purus non enim praesent.</p>
<p>Faucibus purus in massa tempor nec feugiat nisl. Hendrerit gravida rutrum quisque non tellus orci ac auctor. Pretium viverra suspendisse potenti nullam ac tortor vitae purus. Lacus viverra vitae congue eu consequat ac felis. Iaculis urna id volutpat
lacus. Massa tincidunt nunc pulvinar sapien et ligula ullamcorper malesuada. Molestie at elementum eu facilisis sed odio morbi. Ac turpis egestas maecenas pharetra convallis. Aliquet risus feugiat in ante metus dictum at tempor commodo. Tortor
pretium viverra suspendisse potenti nullam ac tortor vitae. Etiam non quam lacus suspendisse faucibus. Nunc lobortis mattis aliquam faucibus purus in. Gravida in fermentum et sollicitudin. Magna etiam tempor orci eu lobortis. Tellus in metus vulputate
eu scelerisque. Purus semper eget duis at tellus at urna condimentum. Blandit aliquam etiam erat velit scelerisque in.</p>
<p>Et malesuada fames ac turpis egestas integer eget. Quis ipsum suspendisse ultrices gravida dictum fusce ut placerat orci. Tincidunt praesent semper feugiat nibh sed. Purus ut faucibus pulvinar elementum. Pretium nibh ipsum consequat nisl vel pretium
lectus. Donec ultrices tincidunt arcu non. Accumsan sit amet nulla facilisi morbi tempus iaculis. Turpis cursus in hac habitasse. Diam volutpat commodo sed egestas egestas fringilla phasellus faucibus. Porttitor massa id neque aliquam vestibulum
morbi blandit. Velit ut tortor pretium viverra suspendisse. Tempus quam pellentesque nec nam aliquam. Odio ut enim blandit volutpat maecenas. Viverra nam libero justo laoreet.</p>
<p>Ut aliquam purus sit amet luctus. Sapien faucibus et molestie ac feugiat sed. Tempus egestas sed sed risus pretium quam vulputate dignissim. Egestas fringilla phasellus faucibus scelerisque. Pretium lectus quam id leo in vitae. Porttitor eget dolor
morbi non arcu risus quis varius. Venenatis lectus magna fringilla urna porttitor rhoncus dolor purus non. Ornare quam viverra orci sagittis eu volutpat odio facilisis mauris. Dictum non consectetur a erat nam at. Blandit massa enim nec dui nunc
mattis enim ut tellus. Volutpat maecenas volutpat blandit aliquam etiam erat. Aliquet enim tortor at auctor urna nunc. Cras sed felis eget velit aliquet sagittis id consectetur. Diam quam nulla porttitor massa id neque aliquam vestibulum morbi.</p>
</div>
</div>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.2.0/js/bootstrap.min.js"></script>

This is a rare case where I'd resort to absolute positioning rather than trying to dance with flexbox.
.chat-tag {
position: absolute; /* <------------- HERE */
top: 100%; /* <------------------ AND HERE */
background-color: rgba(181, 101, 167, 0.5); /* for fun | #B565A7 */
transition: all 0.3s; /* for fun */
display: flex;
align-items: center;
justify-content: center;
height: 50px;
width: 200px;
}
.chat-tag:hover {
background-color: rgba(181, 101, 167, 1); /* for fun */
}
nav {
background-color: red;
height: 48px;
position: sticky;
top: 0;
}
.main-nav {
display: inline-flex;
}
.masthead-fluid {
background-color: #F7CAC9;
}
.masthead {
height: 60vh;
display: inline-flex;
align-items: center;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.0.2/css/bootstrap.min.css" rel="stylesheet" />
<header class="header sticky-top bg-white">
<div class="container-fluid">
<div class="nav-wrapper text-center">
<nav class="main-nav navbar navbar-expand-lg bg-white">
<div class="container-fluid text">
<a class="navbar-brand" href="#">
LOGO
</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="#what">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#registry">Page 1</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Page 2</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Page 3</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Page 4</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Page 5</a>
</li>
</ul>
</div>
</div>
<div class="chat-tag">Chat with us</div>
</nav>
</div>
</div>
</header>
<div class="container-fluid masthead-fluid mb-5">
<div class="row">
<div class="col-12">
<div class="color-overlay d-flex align-items-center">
<div class="container">
<div class="row">
<div class="col-12 masthead">
<h1>Hello, world!</h1>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="container">
<div class="row">
<div class="col-12">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Aliquam id diam maecenas ultricies mi eget mauris pharetra et. Non enim praesent elementum facilisis leo vel fringilla. Feugiat
scelerisque varius morbi enim. Ante metus dictum at tempor. Nec ultrices dui sapien eget mi proin. Accumsan lacus vel facilisis volutpat est velit egestas dui. Sit amet aliquam id diam. Vel fringilla est ullamcorper eget nulla. Malesuada fames
ac turpis egestas sed tempus urna. Lectus nulla at volutpat diam ut venenatis tellus. Et netus et malesuada fames ac turpis egestas integer. Amet nisl suscipit adipiscing bibendum est. Faucibus et molestie ac feugiat. Pretium nibh ipsum consequat
nisl vel pretium lectus. Vulputate mi sit amet mauris commodo quis imperdiet. A diam sollicitudin tempor id eu nisl. In egestas erat imperdiet sed euismod nisi. Aliquam malesuada bibendum arcu vitae elementum curabitur vitae. Nibh sit amet commodo
nulla facilisi nullam vehicula ipsum.</p>
<p>Malesuada fames ac turpis egestas maecenas pharetra convallis posuere morbi. Sit amet porttitor eget dolor morbi non arcu risus. Consectetur libero id faucibus nisl tincidunt eget nullam non. Sed risus ultricies tristique nulla aliquet. Tincidunt
arcu non sodales neque. Scelerisque eleifend donec pretium vulputate sapien nec sagittis. Scelerisque fermentum dui faucibus in ornare quam. Ullamcorper eget nulla facilisi etiam dignissim. Vel elit scelerisque mauris pellentesque pulvinar pellentesque
habitant. Magna fringilla urna porttitor rhoncus dolor purus non enim praesent.</p>
<p>Faucibus purus in massa tempor nec feugiat nisl. Hendrerit gravida rutrum quisque non tellus orci ac auctor. Pretium viverra suspendisse potenti nullam ac tortor vitae purus. Lacus viverra vitae congue eu consequat ac felis. Iaculis urna id volutpat
lacus. Massa tincidunt nunc pulvinar sapien et ligula ullamcorper malesuada. Molestie at elementum eu facilisis sed odio morbi. Ac turpis egestas maecenas pharetra convallis. Aliquet risus feugiat in ante metus dictum at tempor commodo. Tortor
pretium viverra suspendisse potenti nullam ac tortor vitae. Etiam non quam lacus suspendisse faucibus. Nunc lobortis mattis aliquam faucibus purus in. Gravida in fermentum et sollicitudin. Magna etiam tempor orci eu lobortis. Tellus in metus vulputate
eu scelerisque. Purus semper eget duis at tellus at urna condimentum. Blandit aliquam etiam erat velit scelerisque in.</p>
<p>Et malesuada fames ac turpis egestas integer eget. Quis ipsum suspendisse ultrices gravida dictum fusce ut placerat orci. Tincidunt praesent semper feugiat nibh sed. Purus ut faucibus pulvinar elementum. Pretium nibh ipsum consequat nisl vel pretium
lectus. Donec ultrices tincidunt arcu non. Accumsan sit amet nulla facilisi morbi tempus iaculis. Turpis cursus in hac habitasse. Diam volutpat commodo sed egestas egestas fringilla phasellus faucibus. Porttitor massa id neque aliquam vestibulum
morbi blandit. Velit ut tortor pretium viverra suspendisse. Tempus quam pellentesque nec nam aliquam. Odio ut enim blandit volutpat maecenas. Viverra nam libero justo laoreet.</p>
<p>Ut aliquam purus sit amet luctus. Sapien faucibus et molestie ac feugiat sed. Tempus egestas sed sed risus pretium quam vulputate dignissim. Egestas fringilla phasellus faucibus scelerisque. Pretium lectus quam id leo in vitae. Porttitor eget dolor
morbi non arcu risus quis varius. Venenatis lectus magna fringilla urna porttitor rhoncus dolor purus non. Ornare quam viverra orci sagittis eu volutpat odio facilisis mauris. Dictum non consectetur a erat nam at. Blandit massa enim nec dui nunc
mattis enim ut tellus. Volutpat maecenas volutpat blandit aliquam etiam erat. Aliquet enim tortor at auctor urna nunc. Cras sed felis eget velit aliquet sagittis id consectetur. Diam quam nulla porttitor massa id neque aliquam vestibulum morbi.</p>
</div>
</div>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.2.0/js/bootstrap.min.js"></script>

Related

How to display content full width inside bootstrap container

I'm trying to create a carousel slider with css, atm works fine on chrome/firefox/IE, it looks something like this:
Now I want the slider displays full on the screen since it's inside a container, so I added a trick to acomplish that:
margin-left:-2000px;
margin-right:-2000px;
padding-left:2000px;
padding-right:2000px;
background-color: #e2e7fe;
And ended looking something like that:
That works fine on chrome, but on firefox and IE can't fully scroll the content. Is there a better solution that applying negative margins and paddings or fix that issue somehow?
EDIT: I need the slider inside the container since this is an example from my real website where I have more sliders inside the web and not just one on top
<!DOCTYPE html>
<html>
<head>
<title></title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<style type="text/css">
body {
overflow-x: hidden;
background-color: #f0f0e8;
}
.container {
background-color: #e2e7fe;
}
.slider {
white-space: nowrap !important;
overflow-x: auto;
overflow-y: hidden;
margin-left:-2000px;
margin-right:-2000px;
padding-left:2000px;
padding-right:2000px;
background-color: #e2e7fe;
}
.slide {
display: inline-block;
margin: 20px;
}
</style>
</head>
<body>
<div class="container">
<div class="row">
<div class="col-12">
<ul class="slider">
<li class="slide"><img src="https://picsum.photos/id/1068/200/200"></li>
<li class="slide"><img src="https://picsum.photos/id/189/200/200"></li>
<li class="slide"><img src="https://picsum.photos/id/996/200/200"></li>
<li class="slide"><img src="https://picsum.photos/id/603/200/200"></li>
<li class="slide"><img src="https://picsum.photos/id/933/200/200"></li>
<li class="slide"><img src="http://picsum.photos/id/32/200/200"></li>
<li class="slide"><img src="https://picsum.photos/id/21/200/200"></li>
<li class="slide"><img src="https://picsum.photos/id/22/200/200"></li>
<li class="slide"><img src="https://picsum.photos/id/23/200/200"></li>
<li class="slide"><img src="https://picsum.photos/id/24/200/200"></li>
<li class="slide"><img src="https://picsum.photos/id/25/200/200"></li>
<li class="slide"><img src="http://picsum.photos/id/26/200/200"></li>
<li class="slide"><img src="https://picsum.photos/id/27/200/200"></li>
<li class="slide"><img src="https://picsum.photos/id/28/200/200"></li>
<li class="slide"><img src="https://picsum.photos/id/29/200/200"></li>
<li class="slide"><img src="https://picsum.photos/id/30/200/200"></li>
<li class="slide"><img src="https://picsum.photos/id/31/200/200"></li>
<li class="slide"><img src="http://picsum.photos/id/39/200/200"></li>
<li class="slide"><img src="https://picsum.photos/id/33/200/200"></li>
<li class="slide"><img src="https://picsum.photos/id/34/200/200"></li>
<li class="slide"><img src="https://picsum.photos/id/35/200/200"></li>
<li class="slide"><img src="https://picsum.photos/id/36/200/200"></li>
<li class="slide"><img src="https://picsum.photos/id/37/200/200"></li>
<li class="slide"><img src="http://picsum.photos/id/38/200/200"></li>
</ul>
</div>
</div>
<div class="row">
<div class="col-12">
<h1>Some content</h1>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Amet purus gravida quis blandit turpis cursus in hac habitasse. Risus at ultrices mi tempus imperdiet nulla malesuada. Maecenas volutpat blandit aliquam etiam erat velit scelerisque in. Vel pharetra vel turpis nunc eget lorem. Nulla pellentesque dignissim enim sit amet venenatis urna. Tincidunt eget nullam non nisi est sit amet facilisis. Ullamcorper sit amet risus nullam eget felis. Faucibus a pellentesque sit amet. Consectetur lorem donec massa sapien faucibus. Vitae suscipit tellus mauris a diam maecenas sed enim ut. Id velit ut tortor pretium viverra suspendisse potenti. Mi sit amet mauris commodo quis imperdiet. Interdum consectetur libero id faucibus nisl tincidunt eget nullam. A lacus vestibulum sed arcu. Sed libero enim sed faucibus turpis in eu mi. Aenean et tortor at risus viverra. Varius morbi enim nunc faucibus a pellentesque. Egestas sed sed risus pretium quam vulputate dignissim suspendisse.
</p>
<p>
Malesuada fames ac turpis egestas maecenas pharetra convallis. Sed cras ornare arcu dui vivamus arcu felis bibendum ut. Enim facilisis gravida neque convallis a cras semper auctor neque. Eu scelerisque felis imperdiet proin. Mi sit amet mauris commodo quis imperdiet massa. Neque sodales ut etiam sit amet nisl purus in mollis. Pulvinar neque laoreet suspendisse interdum consectetur libero id faucibus. Sem fringilla ut morbi tincidunt augue interdum. Orci porta non pulvinar neque laoreet suspendisse interdum consectetur. Commodo quis imperdiet massa tincidunt nunc pulvinar sapien. Sociis natoque penatibus et magnis. Dignissim convallis aenean et tortor at risus viverra. Feugiat in fermentum posuere urna. Faucibus scelerisque eleifend donec pretium vulputate sapien. Dolor purus non enim praesent elementum. Erat nam at lectus urna duis convallis convallis. Platea dictumst quisque sagittis purus. Ligula ullamcorper malesuada proin libero nunc consequat. Tortor condimentum lacinia quis vel eros donec ac odio tempor.
</p>
<p>
Tristique senectus et netus et malesuada fames ac. Congue nisi vitae suscipit tellus. Interdum consectetur libero id faucibus nisl tincidunt. Mauris vitae ultricies leo integer. Eros in cursus turpis massa tincidunt dui ut ornare lectus. In aliquam sem fringilla ut morbi tincidunt augue interdum velit. Pretium viverra suspendisse potenti nullam ac. Eu nisl nunc mi ipsum faucibus vitae aliquet. Elementum nisi quis eleifend quam adipiscing vitae proin sagittis. Enim lobortis scelerisque fermentum dui faucibus in ornare quam. Enim ut sem viverra aliquet eget sit. Dolor sit amet consectetur adipiscing. Amet nulla facilisi morbi tempus. Vulputate dignissim suspendisse in est ante in. Lectus urna duis convallis convallis tellus id. Vitae semper quis lectus nulla at volutpat diam ut. Est pellentesque elit ullamcorper dignissim cras tincidunt lobortis feugiat. Pretium quam vulputate dignissim suspendisse in est ante. Ac placerat vestibulum lectus mauris. Feugiat pretium nibh ipsum consequat nisl vel pretium lectus quam.
</p>
<p>
Dui id ornare arcu odio. Sed id semper risus in. Amet consectetur adipiscing elit ut aliquam purus sit amet luctus. Est ullamcorper eget nulla facilisi etiam dignissim. Nibh praesent tristique magna sit amet. Turpis egestas pretium aenean pharetra. Maecenas accumsan lacus vel facilisis volutpat. A cras semper auctor neque vitae tempus quam. Ultricies mi eget mauris pharetra et ultrices neque. Enim praesent elementum facilisis leo vel fringilla. Dolor magna eget est lorem ipsum. Sollicitudin aliquam ultrices sagittis orci a scelerisque purus semper eget. Ut tristique et egestas quis. Id cursus metus aliquam eleifend mi in. Rhoncus dolor purus non enim praesent elementum facilisis leo. Sed lectus vestibulum mattis ullamcorper. Senectus et netus et malesuada fames ac turpis. Vestibulum sed arcu non odio euismod. Sagittis id consectetur purus ut faucibus pulvinar elementum.
</p>
<p>
Eget mauris pharetra et ultrices neque ornare. Non sodales neque sodales ut etiam sit amet nisl. Enim ut tellus elementum sagittis vitae et leo duis ut. Augue lacus viverra vitae congue eu consequat. Purus semper eget duis at tellus at. Sed egestas egestas fringilla phasellus faucibus. Libero volutpat sed cras ornare. Venenatis lectus magna fringilla urna porttitor rhoncus. Dolor magna eget est lorem. Sed blandit libero volutpat sed cras ornare. Id cursus metus aliquam eleifend mi in nulla posuere.
</p>
<p>
Velit sed ullamcorper morbi tincidunt ornare massa eget egestas purus. Ante in nibh mauris cursus mattis molestie. Sed elementum tempus egestas sed. Donec adipiscing tristique risus nec feugiat in fermentum posuere. Vitae semper quis lectus nulla at volutpat. Dignissim cras tincidunt lobortis feugiat vivamus at augue eget. Sed libero enim sed faucibus turpis in. Vitae ultricies leo integer malesuada nunc vel risus commodo viverra. Senectus et netus et malesuada fames ac. Dui vivamus arcu felis bibendum ut tristique et. Gravida quis blandit turpis cursus in hac habitasse platea. Viverra accumsan in nisl nisi. Vel risus commodo viverra maecenas accumsan lacus vel. Scelerisque eleifend donec pretium vulputate sapien.
</p>
<p>
Turpis egestas sed tempus urna. Fermentum posuere urna nec tincidunt praesent semper feugiat nibh. Magna ac placerat vestibulum lectus mauris. Lorem ipsum dolor sit amet consectetur adipiscing elit. Consequat id porta nibh venenatis cras sed. Volutpat consequat mauris nunc congue nisi vitae suscipit tellus. Diam quam nulla porttitor massa id neque. Justo eget magna fermentum iaculis eu non diam. Fermentum iaculis eu non diam phasellus. Aliquam ultrices sagittis orci a scelerisque purus semper. Sit amet nisl purus in mollis nunc sed id. Id aliquet risus feugiat in ante metus dictum at tempor. Quisque id diam vel quam elementum pulvinar etiam. Aliquet eget sit amet tellus cras adipiscing enim eu turpis. Venenatis a condimentum vitae sapien. Viverra adipiscing at in tellus integer feugiat scelerisque.
</p>
</div>
</div>
</div>
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
</body>
</html>
Since you don't want to take out the carousel slider div to be out of the container class. There is a fix for that too. I have used viewport width(vw) for it and then calculate it in the right way that the carousel will fit on full screen.
CSS:-
.slider {
white-space: nowrap !important;
overflow-x: auto;
overflow-y: hidden;
margin: 0;
padding: 0;
background-color: #e2e7fe;
width: calc(100vw);
position: relative;
left: 34.5em;
transform: translateX(-50%);
}
But please note that my fix will work only in large screens only (lg) termed in bootstrap. For medium(md), small(sm), and extra small(xs) screens, you have to calculate by yourself with same calculation I used for lg. Just you have to set media query for different resolutions for left position.
Working Fiddle:- https://jsfiddle.net/szreLuwn/2/
Hope, it fulfills your requirement.
Thanks

How to add margins between columns in Bootsrap4?

I try to arrange 3 sections columns equally by assigning either col-lg-4 or col-lg-3 for each of them with Bootsstrap 4.
With col-lg-4 or any responsive combination that takes total of 12 columns, I get no margin between the columns.
With col-lg-3 the margins become too wide.
The same problem arises with both "container" and "container-fluid" class.
I tried also to adjust the margins manually, replacing mx-auto with Bootstrap4 margin set at m-3, but it does not solve the problem because in that case all the columns move to the left, leaving empty space on the right side of the screen.
The problem arises the moment I try to put margins. Otherwise, if there are no margins I can set col-lg-4 without a problem. I will get for instance 3 nice columns. But once I put margins, it becomes wrong. I followed the recommendation on https://getbootstrap.com/docs/4.0/utilities/spacing/ but still it does not help.
* {
box-sizing: border-box;
}
body {
font-size: 16px;
color: black;
background-color: #eeeeee;
font-family: 'Oxygen', sans-serif;
}
.navbar {
background-color: rgb(178, 238, 13);
border-radius: 0;
border: 0;
margin: 0;
padding: 0;
}
#collapsibleNavbar {
background-color: rgb(229, 243, 192);
text-align: center;
}
.navbar-nav li a {
color: black;
border-style: solid;
border-width: 1px;
}
.navbar-brand {
color: black;
padding: 15px;
}
h5{
margin-bottom: 15px;
padding-top: 7px;
}
h2{
font-size: 175%;
margin-bottom: 30px;
margin-top: 20px;
}
.paraf{
background-color: #e6ee9c;
}
<!DOCTYPE html>
<html>
<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>Module 3</title>
<link rel="stylesheet" href="css/bootstrap.min.css">
<link rel="stylesheet" href="styles.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.0/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
</head>
<body>
<header>
<nav class="navbar navbar-expand-md navbar-light">
<a id="get-back" class="navbar-brand" href="#">Food, LLC</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#collapsibleNavbar">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="collapsibleNavbar">
<ul class="d-lg-none d-md-none navbar-nav">
<li class="nav-item">
<a class="nav-link" href="#chicken">Chicken</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#beef">Beef</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#sushi">Sushi</a>
</li>
</ul>
</div>
</nav>
</header>
<h2 class="text-center"> Our Menu </h2>
<div class="container">
<div class="row">
<div class="col-lg-4 col-md-6 col-sm-12 col-12 paraf mx-auto">
<h5 class="text-center" id="chicken">Chicken</h5>
<p>Lorem ipsum dolor sit amet, consectetur felis ut venenatis tortor, nulla fringilla commodo eget ullamcorper
viverra nulla. Quis donec ultricies, in non eget ultricies ut wisi pede. Eget faucibus ligula lacinia, ligula risus quasi,
vestibulum amet mattis mi sit egestas, a velit integer, feugiat lectus et. Ullamcorper ut lobortis est, consequat magnis,
donec lorem posuere sit ridiculus lacinia augue, morbi magna velit pellentesque a vestibulum arcu, in facilisi ultricies
dolor eu dolor quis. Nec eu libero, fermentum sagittis augue wisi wisi adipiscing. Est risus dapibus cursus, praesent
vivamus mattis est, ac euismod quis. Primis diam enim tortor fermentum, varius pede officia pellentesque nibh quam
blandit, accumsan vestibulum interdum vivamus, iaculis wisi lacus sodales facilisi. Molestie accusantium, sed nisl
ratione eu euismod nulla ac, morbi aliquet. Lacus egestas. Purus sem fusce et id nibh mauris, luctus magnis diam morbi
enim, nunc iste, laoreet commodo in tortor lobortis. Congue suspendisse pellentesque eget, nibh pulvinar dolor donec
hac, quis diam at vehicula suspendisse. Eget commodo libero, tortor integer, nec integer, mauris eget iaculis nec
imperdiet dolor eros.
Lorem ipsum dolor sit amet, consectetur felis ut venenatis tortor, nulla fringilla commodo eget ullamcorper
viverra nulla. Quis donec ultricies, in non eget ultricies ut wisi pede. Eget faucibus ligula lacinia, ligula risus quasi,
vestibulum amet mattis mi sit egestas, a velit integer, feugiat lectus et. Ullamcorper ut lobortis est, consequat magnis,
donec lorem posuere sit ridiculus lacinia augue, morbi magna velit pellentesque a vestibulum arcu, in facilisi ultricies
dolor eu dolor quis. Nec eu libero, fermentum sagittis augue wisi wisi adipiscing. Est risus dapibus cursus, praesent
vivamus mattis est, ac euismod quis. Primis diam enim tortor fermentum, varius pede officia pellentesque nibh quam
blandit, accumsan vestibulum interdum vivamus, iaculis wisi lacus sodales facilisi. Molestie accusantium, sed nisl
ratione eu euismod nulla ac, morbi aliquet. Lacus egestas. Purus sem fusce et id nibh mauris, luctus magnis diam morbi
enim, nunc iste, laoreet commodo in tortor lobortis. Congue suspendisse pellentesque eget, nibh pulvinar dolor donec
hac, quis diam at vehicula suspendisse. Eget commodo libero, tortor integer, nec integer, mauris eget iaculis nec
imperdiet dolor eros. <br> (End of Chicken section) Back to Top</p></div>
<div class="col-lg-4 col-md-6 col-sm-12 col-12 paraf mx-auto">
<h5 class="text-center" id="beef">Beef</h5>
<p>Lorem ipsum dolor sit amet, consectetur felis ut venenatis tortor, nulla fringilla commodo eget ullamcorper
viverra nulla. Quis donec ultricies, in non eget ultricies ut wisi pede. Eget faucibus ligula lacinia, ligula risus quasi,
vestibulum amet mattis mi sit egestas, a velit integer, feugiat lectus et. Ullamcorper ut lobortis est, consequat magnis,
donec lorem posuere sit ridiculus lacinia augue, morbi magna velit pellentesque a vestibulum arcu, in facilisi ultricies
dolor eu dolor quis. Nec eu libero, fermentum sagittis augue wisi wisi adipiscing. Est risus dapibus cursus, praesent
vivamus mattis est, ac euismod quis. Primis diam enim tortor fermentum, varius pede officia pellentesque nibh quam
blandit, accumsan vestibulum interdum vivamus, iaculis wisi lacus sodales facilisi. Molestie accusantium, sed nisl
ratione eu euismod nulla ac, morbi aliquet. Lacus egestas. Purus sem fusce et id nibh mauris, luctus magnis diam morbi
enim, nunc iste, laoreet commodo in tortor lobortis. Congue suspendisse pellentesque eget, nibh pulvinar dolor donec
hac, quis diam at vehicula suspendisse. Eget commodo libero, tortor integer, nec integer, mauris eget iaculis nec
imperdiet dolor eros.
Lorem ipsum dolor sit amet, consectetur felis ut venenatis tortor, nulla fringilla commodo eget ullamcorper
viverra nulla. Quis donec ultricies, in non eget ultricies ut wisi pede. Eget faucibus ligula lacinia, ligula risus quasi,
vestibulum amet mattis mi sit egestas, a velit integer, feugiat lectus et. Ullamcorper ut lobortis est, consequat magnis,
donec lorem posuere sit ridiculus lacinia augue, morbi magna velit pellentesque a vestibulum arcu, in facilisi ultricies
dolor eu dolor quis. Nec eu libero, fermentum sagittis augue wisi wisi adipiscing. Est risus dapibus cursus, praesent
vivamus mattis est, ac euismod quis. Primis diam enim tortor fermentum, varius pede officia pellentesque nibh quam
blandit, accumsan vestibulum interdum vivamus, iaculis wisi lacus sodales facilisi. Molestie accusantium, sed nisl
ratione eu euismod nulla ac, morbi aliquet. Lacus egestas. Purus sem fusce et id nibh mauris, luctus magnis diam morbi
enim, nunc iste, laoreet commodo in tortor lobortis. Congue suspendisse pellentesque eget, nibh pulvinar dolor donec
hac, quis diam at vehicula suspendisse. Eget commodo libero, tortor integer, nec integer, mauris eget iaculis nec
imperdiet dolor eros.<br>(End of Beef section) Back to Top</p></div>
<div class="col-lg-4 col-md-12 col-sm-12 col-12 paraf mx-auto">
<h5 class="text-center" id="sushi">Sushi</h5>
<p>Lorem ipsum dolor sit amet, consectetur felis ut venenatis tortor, nulla fringilla commodo eget ullamcorper
viverra nulla. Quis donec ultricies, in non eget ultricies ut wisi pede. Eget faucibus ligula lacinia, ligula risus quasi,
vestibulum amet mattis mi sit egestas, a velit integer, feugiat lectus et. Ullamcorper ut lobortis est, consequat magnis,
donec lorem posuere sit ridiculus lacinia augue, morbi magna velit pellentesque a vestibulum arcu, in facilisi ultricies
dolor eu dolor quis. Nec eu libero, fermentum sagittis augue wisi wisi adipiscing. Est risus dapibus cursus, praesent
vivamus mattis est, ac euismod quis. Primis diam enim tortor fermentum, varius pede officia pellentesque nibh quam
blandit, accumsan vestibulum interdum vivamus, iaculis wisi lacus sodales facilisi. Molestie accusantium, sed nisl
ratione eu euismod nulla ac, morbi aliquet. Lacus egestas. Purus sem fusce et id nibh mauris, luctus magnis diam morbi
enim, nunc iste, laoreet commodo in tortor lobortis. Congue suspendisse pellentesque eget, nibh pulvinar dolor donec
hac, quis diam at vehicula suspendisse. Eget commodo libero, tortor integer, nec integer, mauris eget iaculis nec
imperdiet dolor eros.
Lorem ipsum dolor sit amet, consectetur felis ut venenatis tortor, nulla fringilla commodo eget ullamcorper
viverra nulla. Quis donec ultricies, in non eget ultricies ut wisi pede. Eget faucibus ligula lacinia, ligula risus quasi,
vestibulum amet mattis mi sit egestas, a velit integer, feugiat lectus et. Ullamcorper ut lobortis est, consequat magnis,
donec lorem posuere sit ridiculus lacinia augue, morbi magna velit pellentesque a vestibulum arcu, in facilisi ultricies
dolor eu dolor quis. Nec eu libero, fermentum sagittis augue wisi wisi adipiscing. Est risus dapibus cursus, praesent
vivamus mattis est, ac euismod quis. Primis diam enim tortor fermentum, varius pede officia pellentesque nibh quam
blandit, accumsan vestibulum interdum vivamus, iaculis wisi lacus sodales facilisi. Molestie accusantium, sed nisl
ratione eu euismod nulla ac, morbi aliquet. Lacus egestas. Purus sem fusce et id nibh mauris, luctus magnis diam morbi
enim, nunc iste, laoreet commodo in tortor lobortis. Congue suspendisse pellentesque eget, nibh pulvinar dolor donec
hac, quis diam at vehicula suspendisse. Eget commodo libero, tortor integer, nec integer, mauris eget iaculis nec
imperdiet dolor eros.<br>(End of Sushi section) Back to Top</p></div>
</div>
</div>
</body>
</html>
Can you suggest how to fix this and get margins between the columns.
You can use the col-lg-4 while using padding so it would look like they're separated and come out as:
<div class="col-lg-4 px-1 (other classes...)">
</div>
<div class="col-lg-4 px-1 (other classes...)">
</div>
<div class="col-lg-4 px-1 (other classes...)">
</div>
Just add mt-2 and mb-2 in your class col-md-3.
<div class="col-lg-4">
<div class="col-lg-12">
your content 1
</div>
</div>
<div class="col-lg-4">
<div class="col-lg-12">
your content 2
</div>
</div>
<div class="col-lg-4">
<div class="col-lg-12">
your content 3
</div>
</div>
so just add col-lg-12 in col-lg-4

Stop Bootstrap 4 footer from rising up

My bootstrap 4 footer rises up on pages where the body has less content.
Below is an image of the problem.
footerproblem
footer {
background-color: white;
color: #d5d5d5;
padding-top: 1rem;
}
footer a {
color: #d5d5d5;
}
hr.light-100 {
border-top: 1px solid #d5d5d5;
width: 100%;
margin-top: .8rem;
margin-bottom: 1rem;
color: black;
}
<footer>
<div class="container-fluid padding">
<div class="row text-center">
<div class="col-md-6">
<p class="marker">blah blah blah.
<a class="btn btn-social-icon btn-instagram">
<span class="fa fa-instagram"></span>
</a>
</div>
<div class="col-md-6">
<p class="marker">more blah blah.
<a class="btn btn-social-icon btn-facebook">
<span class="fa fa-facebook"></span>
</a>
</p>
</div>
<div class="col-12">
<hr class="light-100">
<h5>© app.com</h5>
</div>
</div>
</div>
If there is anything else I have forgot to attach please let me know and I will edit the post.
I have played around with footer: sticky; / fixed; but that does not solve the problem.
The footer is also too tall but whenever I have added in a height css variable, the height is reduced however the text stays in place.
funkyheight
Thank you very much for your help.
The proper way to fix this problem is to layout your page as follows:
<body>
<header></header>
<main></main>
<footer></footer>
</body>
with the following CSS:
body {
display: flex;
flex-direction: column;
margin: 0;
min-height: 100vh;
}
header, footer {
flex-grow: 0;
}
main {
flex-grow: 1;
}
This works with or without Bootstrap, but if you're not using Bootstrap you probably also want
* { box-sizing: border-box; }
(which is already included in Bootstrap).
Here's an example, using Bootstrap v4:
body {
display: flex;
flex-direction: column;
margin: 0;
min-height: 100vh;
}
header, footer {
flex-grow: 0;
}
main {
flex-grow: 1;
}
footer {
background-color: #eee;
}
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css">
<title>Hello, world!</title>
</head>
<body>
<header>
<nav class="navbar navbar-expand-md navbar-dark bg-dark">
<a class="navbar-brand" href="#">Logo</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarCollapse" aria-controls="navbarCollapse" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarCollapse">
<ul class="navbar-nav mr-auto">
<li class="nav-item active">
<a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link disabled" href="#">Disabled</a>
</li>
</ul>
<form class="form-inline mt-2 mt-md-0">
<input class="form-control mr-sm-2" type="text" placeholder="Search" aria-label="Search">
<button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
</form>
</div>
</nav>
</header>
<main role="main">
<div class="container">
<h1>Hello, world!</h1>
<div class="row">
<div class="col">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Aliquam ut porttitor leo a. Metus dictum at tempor commodo. Feugiat vivamus at augue eget arcu dictum. Amet consectetur adipiscing elit duis tristique sollicitudin nibh. In fermentum posuere urna nec tincidunt praesent semper feugiat nibh. Elementum eu facilisis sed odio morbi quis commodo odio. Tempus egestas sed sed risus. Pellentesque elit ullamcorper dignissim cras tincidunt lobortis. Eu ultrices vitae auctor eu augue ut. Viverra suspendisse potenti nullam ac tortor vitae purus faucibus ornare. In pellentesque massa placerat duis. Bibendum enim facilisis gravida neque convallis.
<p>Nisi vitae suscipit tellus mauris a. Non blandit massa enim nec dui nunc. Hac habitasse platea dictumst vestibulum rhoncus. Vitae congue mauris rhoncus aenean vel. In fermentum et sollicitudin ac orci phasellus egestas. Turpis cursus in hac habitasse platea dictumst quisque sagittis purus. Diam sollicitudin tempor id eu nisl nunc mi ipsum. Nunc mattis enim ut tellus. Ultrices dui sapien eget mi proin sed libero. Vitae tortor condimentum lacinia quis vel eros donec ac odio. Sodales ut eu sem integer vitae justo eget magna. Pellentesque id nibh tortor id aliquet. Sed pulvinar proin gravida hendrerit lectus a.
<p>Sed velit dignissim sodales ut eu sem integer. Senectus et netus et malesuada fames ac. Arcu non sodales neque sodales ut etiam sit amet nisl. Velit scelerisque in dictum non. Integer eget aliquet nibh praesent tristique. Dictumst quisque sagittis purus sit. Quam elementum pulvinar etiam non quam lacus. Ipsum dolor sit amet consectetur adipiscing elit. Sed egestas egestas fringilla phasellus faucibus scelerisque eleifend. Velit egestas dui id ornare arcu odio ut sem. Nec dui nunc mattis enim ut tellus elementum sagittis. Nulla facilisi cras fermentum odio. Nunc pulvinar sapien et ligula ullamcorper malesuada proin. Magna eget est lorem ipsum. Vitae tortor condimentum lacinia quis vel eros donec ac. Eget egestas purus viverra accumsan in nisl nisi scelerisque eu. Mollis nunc sed id semper risus in. Id nibh tortor id aliquet lectus proin. Netus et malesuada fames ac.
</div>
<div class="col">
<p>Mi ipsum faucibus vitae aliquet nec. Diam vel quam elementum pulvinar etiam non. Sit amet risus nullam eget felis eget nunc lobortis mattis. Integer malesuada nunc vel risus commodo. Ut faucibus pulvinar elementum integer enim neque. Id interdum velit laoreet id donec ultrices tincidunt. Sodales ut etiam sit amet nisl purus in. Et sollicitudin ac orci phasellus egestas. Leo integer malesuada nunc vel risus commodo viverra maecenas. Amet cursus sit amet dictum sit amet. In hac habitasse platea dictumst quisque sagittis purus sit amet. Congue mauris rhoncus aenean vel. Imperdiet proin fermentum leo vel orci porta non. Velit dignissim sodales ut eu. Mauris a diam maecenas sed enim ut sem viverra aliquet. Morbi non arcu risus quis varius quam quisque. Blandit aliquam etiam erat velit scelerisque in. Convallis aenean et tortor at risus viverra adipiscing at in. In hac habitasse platea dictumst vestibulum. Euismod nisi porta lorem mollis aliquam ut porttitor leo a.
<p>Non sodales neque sodales ut etiam sit amet. Quis ipsum suspendisse ultrices gravida dictum fusce ut. Lectus proin nibh nisl condimentum id venenatis a. Turpis nunc eget lorem dolor sed viverra ipsum nunc. Amet volutpat consequat mauris nunc congue nisi vitae suscipit. Sollicitudin aliquam ultrices sagittis orci a scelerisque purus semper eget. Libero id faucibus nisl tincidunt. Ac turpis egestas maecenas pharetra convallis posuere morbi leo urna. Sagittis id consectetur purus ut faucibus pulvinar elementum integer enim. Maecenas accumsan lacus vel facilisis volutpat. Bibendum arcu vitae elementum curabitur vitae. Id porta nibh venenatis cras sed felis eget velit. Leo integer malesuada nunc vel. Purus in mollis nunc sed id semper risus in hendrerit. Ut enim blandit volutpat maecenas volutpat blandit aliquam. Eget nunc lobortis mattis aliquam. Suspendisse in est ante in nibh mauris cursus mattis. Nibh mauris cursus mattis molestie a iaculis. Eget dolor morbi non arcu risus quis varius quam quisque. Volutpat maecenas volutpat blandit aliquam etiam erat velit.
</div>
</div>
</div>
</main>
<footer class="footer mt-auto py-3">
<div class="container">
<span class="text-muted">I'm your footer. Always at the bottom of the screen. When the page content is too tall, I get pushed down. I also adjust my height according to my contents.</span>
</div>
</footer>
<!-- Optional JavaScript -->
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.6/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/js/bootstrap.min.js"></script>
</body>
</html>
You can use clearfix.
Just add it as class - effectively what it does is this:
.clearfix::after {
display: block;
clear: both;
content: "";
}

How to get a side nav to be full height regardless of the size of the content

I know this question is probably the same as some that has been asked, but I haven't found a solution yet.
I'm trying to create a site that has a side main navigation on the left and the content on the right.
I've been able to make the nav to be full height on the browser but if the content is bigger then the screen then the nav doesn't go all the way down.
I've created a codepen to show what I'm trying to say.
CODEPEN
My HTML
<!-- BEGIN MENU AREA -->
<nav class="navbar navbar-default navbar-inverse">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<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>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li class="current">Home</li>
<li>About</li>
<li>Gallery</li>
<li>Pricing</li>
<li>Contact</li>
</ul>
</div><!-- /.navbar-collapse -->
</div><!-- /.container-fluid -->
</nav>
<!-- END MENU AREA -->
<!-- BEGIN CONTENT AREA -->
<div class="container content_wrapper">
<div class="row">
<div class="col-lg-12 banner_wrapper">
<div class="single-item">
<div>
<img src="img/banner6.jpg" alt="">
</div>
<div>
<img src="img/banner7.jpg" alt="">
</div>
<div>
<img src="img/banner8.jpg" alt="">
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-lg-12 services_wrapper">
<div class="col-lg-4 services">
<div>
<img src="img/cutting_and_styling.jpg">
<h1>Cutting & Styling</h1>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec a urna aliquet, vulputate orci nec, mattis sem.
Donec sollicitudin sed nibh ut rutrum. Sed tincidunt libero vitae quam lacinia, eget condimentum sem euismod.
Maecenas condimentum felis eu urna sagittis, ut mollis elit luctus. Mauris nibh orci, sodales et malesuada vitae,
suscipit et metus. Praesent non porttitor lorem, at pretium eros.
</p>
</div>
</div>
<div class="col-lg-4 services">
<div>
<img src="img/Chemical_service.jpg">
<h1>Chemical Service</h1>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec a urna aliquet, vulputate orci nec, mattis sem.
Donec sollicitudin sed nibh ut rutrum. Sed tincidunt libero vitae quam lacinia, eget condimentum sem euismod.
Maecenas condimentum felis eu urna sagittis, ut mollis elit luctus. Mauris nibh orci, sodales et malesuada vitae,
suscipit et metus. Praesent non porttitor lorem, at pretium eros.
</p>
</div>
</div>
<div class="col-lg-4 services">
<div>
<img src="img/hair_treatment.jpg">
<h1>Treatment</h1>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec a urna aliquet, vulputate orci nec, mattis sem.
Donec sollicitudin sed nibh ut rutrum. Sed tincidunt libero vitae quam lacinia, eget condimentum sem euismod.
Maecenas condimentum felis eu urna sagittis, ut mollis elit luctus. Mauris nibh orci, sodales et malesuada vitae,
suscipit et metus. Praesent non porttitor lorem, at pretium eros.
</p>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-lg-12 line">
<hr>
</div>
</div>
<div class="row">
<div class="col-lg-12 home_content_area">
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam mi eros, porta rutrum lacinia quis, tristique
molestie dui. Fusce interdum cursus eros, quis tincidunt mi. In vel neque non metus aliquet malesuada. Suspendisse
aliquet purus ac justo cursus dictum. Donec viverra sapien sit amet ligula pretium aliquet. Curabitur suscipit
faucibus purus quis luctus. Pellentesque congue vestibulum interdum. Sed in laoreet turpis, eu condimentum elit.
</p>
<p>
Aenean ipsum ex, gravida non auctor nec, interdum non nulla. Nullam vehicula felis id lacus ullamcorper, eu mollis
mi pulvinar. In at libero nunc. Aliquam a lectus ac quam consequat egestas. Etiam a accumsan diam. Donec sed urna
ut nunc placerat ultrices. Vestibulum ac blandit mauris, quis ultricies justo. Quisque semper mattis purus eu aliquet.
</p>
<p>
In tincidunt malesuada leo, euismod ornare magna mattis a. Aenean fringilla eros ut enim dictum, dapibus porttitor
lectus egestas. Vestibulum ut erat bibendum, laoreet lacus eu, molestie est. Proin bibendum mauris et felis lobortis,
quis consequat libero tincidunt. Donec leo ligula, porttitor ut auctor vel, malesuada et nisl. Donec condimentum
malesuada sem sed rhoncus. Cras vitae tincidunt velit.
</p>
<p>
Mauris maximus ultricies ullamcorper. Praesent auctor euismod dignissim. Donec finibus, leo ut dictum tempus,
lacus sem aliquet ligula, sed ornare nibh neque eleifend elit. Pellentesque semper convallis odio. Maecenas
pharetra iaculis lacus sed ultricies. Sed id sapien aliquet lectus sagittis semper. Etiam ultrices odio sed
dolor dictum commodo. Donec condimentum ac nisl eget vestibulum. Integer velit risus, interdum eget molestie in,
faucibus ut magna. In imperdiet nisi erat, ut vehicula eros volutpat eget. Aliquam at lorem lacinia, accumsan
nunc vitae, sollicitudin velit. Ut at dapibus dolor, ac ornare eros. Etiam dui sem, mollis eget lacus non,
condimentum maximus lectus. Etiam eros sapien, ultricies scelerisque pellentesque eget, viverra a sapien.
Quisque tincidunt ante accumsan blandit ultrices. Maecenas blandit facilisis dignissim.
</p>
</div>
</div>
</div>
<!-- END CONTENT AREA -->
My css
body{
background-color: #4169E1;
background-image: url("../img/light-grey-floral-motif.png");
}
.container{
background: #ffffff none repeat scroll 0 0;
border-radius: 5px;
margin-left: 275px;
margin-top: 20px;
padding: 20px;
width: 970px;
}
.navbar-default {
height: 100%;
left: 0;
position: absolute;
top: 0;
background-image: url("../img/light-grey-floral-motif.png");
}
.navbar-brand {
float: none;
}
.navbar-nav {
/*margin-top: 60px;*/
text-align: center;
width: 100%;
}
.navbar-nav li {
display: block;
float: none;
}
.webkrunch {
bottom: 0;
color: #ffffff;
position: absolute;
}
.webkrunch a img {
margin-left: 40px;
}
.services img {
width: 100%;
}
.banner_wrapper img {
width: 100%;
}
.banner_wrapper {
margin-bottom: 20px;
}
.gallery_image > img {
width: 100%;
}
.services_wrapper h1 {
font-family: Gabriela;
font-size: 26px;
}
.services div {
background: #d6eaf8 none repeat scroll 0 0;
}
.services_wrapper {
text-align: center;
}
.services_wrapper p {
padding: 0 20px 15px;
}
.line hr {
border-color: #333;
border-width: 2px;
width: 80%;
}
.home_content_area {
text-align: center;
}
.services {
padding-left: 0;
}
.services:last-child {
padding: 0;
}
.about_content_area h1 {
font-family: Gabriela;
margin-top: 0;
text-decoration: underline;
}
.gallery_title h2 {
font-family: Gabriela;
}
.gallery_title {
color: #333;
padding-bottom: 1px;
text-align: center;
vertical-align: middle;
}
.gallery_category {
background: #d6eaf8;
}
.gallery_area h1 {
font-family: Gabriela;
}
.gallery_items img {
margin-bottom: 10px;
margin-right: 10px;
}
.pricing_table tr:first-child {
font-weight: bold;
}
.table-striped > tbody > tr:nth-of-type(2n+1) {
background-color: #d6eaf8;
}
table.pricing_table tr td:first-child {
font-weight: bold;
}
You need to add position:fixed; CSS to your navbar. It will be fixed in the browser window and will not scroll.
DEMO
Try position: fixed instead of absolute.
A fixed element is positioned relative to the viewport, it will always stay in the same place (even if the page is scrolled).
Example
The solution to my answer was to change absolute to fixed. The answer came from both #NarenMurali and #James.
Thanks for helping me.
add overall section for both navbar and container and then add this css, sorry i don't have codepen login
.navbar{
padding-bottom:1000px;
margin-bottom:-1000px;
}
.overall{
overflow:hidden;
}
<!-- BEGIN MENU AREA -->
<section class="overall">
<nav class="navbar navbar-default navbar-inverse">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<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>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li class="current">Home</li>
<li>About</li>
<li>Gallery</li>
<li>Pricing</li>
<li>Contact</li>
</ul>
</div><!-- /.navbar-collapse -->
</div><!-- /.container-fluid -->
</nav>
<!-- END MENU AREA -->
<!-- BEGIN CONTENT AREA -->
<div class="container content_wrapper">
<div class="row">
<div class="col-lg-12 banner_wrapper">
<div class="single-item">
<div>
<img src="img/banner6.jpg" alt="">
</div>
<div>
<img src="img/banner7.jpg" alt="">
</div>
<div>
<img src="img/banner8.jpg" alt="">
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-lg-12 services_wrapper">
<div class="col-lg-4 services">
<div>
<img src="img/cutting_and_styling.jpg">
<h1>Cutting & Styling</h1>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec a urna aliquet, vulputate orci nec, mattis sem.
Donec sollicitudin sed nibh ut rutrum. Sed tincidunt libero vitae quam lacinia, eget condimentum sem euismod.
Maecenas condimentum felis eu urna sagittis, ut mollis elit luctus. Mauris nibh orci, sodales et malesuada vitae,
suscipit et metus. Praesent non porttitor lorem, at pretium eros.
</p>
</div>
</div>
<div class="col-lg-4 services">
<div>
<img src="img/Chemical_service.jpg">
<h1>Chemical Service</h1>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec a urna aliquet, vulputate orci nec, mattis sem.
Donec sollicitudin sed nibh ut rutrum. Sed tincidunt libero vitae quam lacinia, eget condimentum sem euismod.
Maecenas condimentum felis eu urna sagittis, ut mollis elit luctus. Mauris nibh orci, sodales et malesuada vitae,
suscipit et metus. Praesent non porttitor lorem, at pretium eros.
</p>
</div>
</div>
<div class="col-lg-4 services">
<div>
<img src="img/hair_treatment.jpg">
<h1>Treatment</h1>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec a urna aliquet, vulputate orci nec, mattis sem.
Donec sollicitudin sed nibh ut rutrum. Sed tincidunt libero vitae quam lacinia, eget condimentum sem euismod.
Maecenas condimentum felis eu urna sagittis, ut mollis elit luctus. Mauris nibh orci, sodales et malesuada vitae,
suscipit et metus. Praesent non porttitor lorem, at pretium eros.
</p>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-lg-12 line">
<hr>
</div>
</div>
<div class="row">
<div class="col-lg-12 home_content_area">
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam mi eros, porta rutrum lacinia quis, tristique
molestie dui. Fusce interdum cursus eros, quis tincidunt mi. In vel neque non metus aliquet malesuada. Suspendisse
aliquet purus ac justo cursus dictum. Donec viverra sapien sit amet ligula pretium aliquet. Curabitur suscipit
faucibus purus quis luctus. Pellentesque congue vestibulum interdum. Sed in laoreet turpis, eu condimentum elit.
</p>
<p>
Aenean ipsum ex, gravida non auctor nec, interdum non nulla. Nullam vehicula felis id lacus ullamcorper, eu mollis
mi pulvinar. In at libero nunc. Aliquam a lectus ac quam consequat egestas. Etiam a accumsan diam. Donec sed urna
ut nunc placerat ultrices. Vestibulum ac blandit mauris, quis ultricies justo. Quisque semper mattis purus eu aliquet.
</p>
<p>
In tincidunt malesuada leo, euismod ornare magna mattis a. Aenean fringilla eros ut enim dictum, dapibus porttitor
lectus egestas. Vestibulum ut erat bibendum, laoreet lacus eu, molestie est. Proin bibendum mauris et felis lobortis,
quis consequat libero tincidunt. Donec leo ligula, porttitor ut auctor vel, malesuada et nisl. Donec condimentum
malesuada sem sed rhoncus. Cras vitae tincidunt velit.
</p>
<p>
Mauris maximus ultricies ullamcorper. Praesent auctor euismod dignissim. Donec finibus, leo ut dictum tempus,
lacus sem aliquet ligula, sed ornare nibh neque eleifend elit. Pellentesque semper convallis odio. Maecenas
pharetra iaculis lacus sed ultricies. Sed id sapien aliquet lectus sagittis semper. Etiam ultrices odio sed
dolor dictum commodo. Donec condimentum ac nisl eget vestibulum. Integer velit risus, interdum eget molestie in,
faucibus ut magna. In imperdiet nisi erat, ut vehicula eros volutpat eget. Aliquam at lorem lacinia, accumsan
nunc vitae, sollicitudin velit. Ut at dapibus dolor, ac ornare eros. Etiam dui sem, mollis eget lacus non,
condimentum maximus lectus. Etiam eros sapien, ultricies scelerisque pellentesque eget, viverra a sapien.
Quisque tincidunt ante accumsan blandit ultrices. Maecenas blandit facilisis dignissim.
</p>
</div>
</div>
</div>
</section>
<!-- END CONTENT AREA -->

Text moving up and down because of bootstrap carousel indicators

I have problem with content under text carousel because, all content under carousel moving up and down when slidiging carousel, I position indicators to be under text, what is best solution in this case?
http://codepen.io/anon/pen/MwGLJd
HTML
<div class="about mainContainer">
<div class="row">
<div class="col-sm-offset-2 col-sm-8">
<h2 class="fontraleway">WHO WE ARE?</h2>
<div id="locations" class="carousel slide" data-ride="carousel">
<ol class="carousel-indicators">
<li data-target="#locations" data-slide-to="0" class="active"></li>
<li data-target="#locations" data-slide-to="1"></li>
<li data-target="#locations" data-slide-to="2"></li>
<li data-target="#locations" data-slide-to="3"></li>
</ol>
<div class="carousel-inner">
<div class="item active">
<center>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque iaculis rhoncus finibus. Donec tempor mi massa, a sollicitudin diam semper ut. Nam pulvinar nisi nisi, vitae rhoncus purus rhoncus id. Nam ac augue sed erat consequat efficitur. Integer aliquet elit et velit porttitor, eget blandit arcu venenatis. Donec fringilla urna purus, sit amet malesuada est dignissim mattis. Donec cursus, quam vel luctus blandit, dui sapien interdum sapien, vitae ultrices arcu leo et augue. Vestibulum fermentum nulla augue, in ultrices risus rutrum a. Suspendisse sed porttitor tellus. Ut vitae vulputate sapien, a facilisis quam.
</center>
</div>
<div class="item">
<center>
Ut eu iaculis arcu. Cras pretium lacus eget mi mattis sollicitudin. Vivamus posuere vehicula mi eu condimentum. Donec eros dolor, sagittis quis arcu non, pulvinar euismod turpis. Suspendisse accumsan sodales massa, eget pretium nunc rhoncus a. Fusce a magna sit amet odio ullamcorper dapibus nec quis nulla. Curabitur enim risus, convallis at felis non, consectetur efficitur risus. Class aptent taciti eptos himenaeos. Nulla facilisi. Aliquam posuere feugiat risus, non mollis nunc iaculis nec. Praesent non tellus rhoncus
</center>
</div>
<div class="item">
<center>
Sed eget luctus leo, eu sagittis felis. Vestibulum et tellus sed neque gravida pretium vel pellentesque tellus. Nullam in dolor magna. Donec in mauris eget nisl volutpat ornare a ut dolor. Vestibulum sit amet felis et purus sagittis interdum. Quisque quis nisi neque. In viverra lobortis ex in auctor. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Ut at nulla augue. Duis et congue erat. Maecenas odio justo, finibus at nulla at, luctus elementum eros. Quisque eget nisl felis. Phasellus tempus imperdiet dui condimentum bibendum. Sed a turpis quis diam ullamcorper interdum in at lectus
</center>
</div>
<div class="item">
<center>
Ut eu iaculis arcu. Cras pretium lacus eget mi mattis sollicitudin. Vivamus posuere vehicula mi eu condimentum. Donec eros dolor, sagittis quis arcu non, pulvinar euismod turpis. Suspendisse accumsan sodales massa, eget pretium nunc rhoncus a. Fusce a magna sit amet odio ullamcorper dapibus nec quis nulla. Curabitur enim risus, convallis at felis non, consectetur efficitur risus. Class aptent taciti eptos himenaeos. Nulla facilisi. Aliquam posuere feugiat risus, non mollis nunc iaculis nec. Praesent non tellus rhoncus
</center>
</div>
</div>
</div>
</div>
</div><!--Closed div row-->
</div><!--Closed div about-->
<div style="clear:both"></div>
<div class="content2">
<p>lor sit amet, consectetur adipiscing elit. Pellentesque iaculis rhoncus finibus. Donec tempor mi massa, a sollicitudin diam semper ut. Nam pulvinar nisi nisi, vitae rhoncus purus rhoncus id. Nam ac augue sed erat consequat efficitur. Integer aliquet elit et velit porttitor, eget blandit arcu venenatis. Donec fringilla urna purus, sit amet malesuada est dignissim mattis. Donec cursus, quam vel luctus blandit, dui sapien interdum sapien, vitae ultrices arcu leo et augue. Vestibulum fer</p>
</div>
CSS
.services h2{
margin-top: 97px;
}
.carousel-indicators li{
background-color: transparent;
border:2px solid #dbdbdb;
overflow:hidden;
}
.carousel-indicators .active{
background-color: #3eb8df;
border:2px solid #3eb8df;
}
.carousel-indicators{
bottom:-60px !important;
}
.carousel-indicators li{
width:15px !important;
height:15px !important;
}
.content2{
margin-top:100px;
color:blue
}
If content for carousel is static use height for class "carousel-inner"
If content is dynamic then you have to find the mx height of item and then assign.