Get fixed position element to not block other content - css

Say I am creating a navigation bar using the header element:
header {
border: 1px solid #a2a2a2;
width: 100vw;
height: 150px;
position: fixed;
top: 0;
z-index: 1;
}
Now when the user scrolls down, the navigation bar obviously covers 150px of content. Is there a way to tell all the elements below this fixed navigation bar to "clear" it or something like that? So that the navigation bar remains fixed but does not cover content?
* {
box-sizing: border-box;
padding: 0;
margin: 0;
}
ul {
margin: 0;
padding: 0;
list-style: none;
}
h2,
h3,
a {
color: #34495e;
}
a {
text-decoration: none;
}
.logo {
margin: 0;
font-size: 1.45em;
}
.main-nav {
margin-top: 5px;
}
.logo a,
.main-nav a {
padding: 10px 15px;
text-transform: uppercase;
text-align: center;
display: block;
}
.main-nav a {
color: #34495e;
font-size: .99em;
}
.main-nav a:hover {
color: #718daa;
}
.header {
height: 150px;
padding-top: .5em;
padding-bottom: .5em;
border: 1px solid #a2a2a2;
background-color: #f4f4f4;
-webkit-box-shadow: 0px 0px 14px 0px rgba(0, 0, 0, 0.75);
-moz-box-shadow: 0px 0px 14px 0px rgba(0, 0, 0, 0.75);
box-shadow: 0px 0px 14px 0px rgba(0, 0, 0, 0.75);
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
width: 100vw;
position: fixed;
top: 0;
z-index: 1;
}
/* =================================
Media Queries
==================================== */
#media (min-width: 769px) {
.header,
.main-nav {
display: flex;
}
.header {
flex-direction: column;
align-items: center;
.header {
width: 80%;
margin: 0 auto;
max-width: 1150px;
}
}
}
#media (min-width: 1025px) {
.header {
flex-direction: row;
justify-content: space-between;
}
}
.parallex {
background: url("https://scontent-lga3-1.xx.fbcdn.net/v/t31.0-8/277233_456825154330649_1101536084_o.jpg?_nc_cat=106&_nc_ht=scontent-lga3-1.xx&oh=a23cf28b01ae96e2585b36164a747906&oe=5D567AAB") no-repeat center bottom /cover;
background-attachment: fixed;
height: 100vh;
}
.text-in-parallex {
position: relative;
top: 70vh;
left: 28vw;
color: white;
font-size: 45px;
}
body {
background-color: #EEEEEE;
/* #EE2324 */
}
.menu-grid {
display: grid;
grid-template-columns: 1fr 3fr;
width: 80%;
margin: 20px auto 100px auto;
padding-bottom: 100px;
border: 1px solid lightgray;
background-color: white;
border-radius: 3px;
/* Shadow */
-moz-box-shadow: 0px 3px 30px 1px #ccc;
-webkit-box-shadow: 0px 3px 30px 1px #ccc;
box-shadow: 10px 15px 30px 15px #ccc;
font-family: 'Alice', serif;
}
.table-of-contents {
padding: 20px;
position: sticky;
top: 0;
height: 100vh;
}
.table-of-contents>h2 {
text-align: center;
margin-bottom: 10px;
}
.inner-menu-grid {
display: grid;
grid-template-columns: 1fr 1fr;
grid-gap: 20px;
background-color: white;
padding: 20px 20px 25px 20px;
border-radius: 3px;
}
.menu-item {
display: flex;
justify-content: space-between;
}
.price {
font-size: 20px;
}
.menu-section {
font-family: "Open Sans", Arial, sans-serif;
font-size: 20.9368px;
font-weight: 400;
margin-bottom: 10px;
}
.menu-section>a {
text-decoration: none;
color: #999999;
padding-left: 7px;
}
.menu-section>a:hover {
border-left: 1px solid blue;
color: #1f5ea9;
text-decoration: underline;
}
.name-of-food {
font-size: 20px;
}
.food-description {
color: grey;
font-style: italic;
}
.food-section {
grid-column: 1 / 3;
text-align: center;
padding-top: 20px;
font-size: 2em;
}
.food-section:nth-child(1) {
padding-top: 0;
}
.restaurant-info {
grid-column: 1 / 3;
text-align: center;
border: 1px solid lightgray;
padding: 20px 0px;
}
#search-form {
border-radius: 3px;
text-align: center;
margin-bottom: 10px;
}
#search-input {
width: 80%;
}
.fab {
padding: 10px;
font-size: 30px;
text-align: center;
text-decoration: none;
margin: 5px 2px;
border-radius: 3px;
}
.fab:hover {
opacity: 0.7;
cursor: pointer;
}
.fa-facebook-square {
background: #3B5998;
color: white;
}
<header class="header">
<h1 class="logo">Flexbox</h1>
<ul class="main-nav">
<li>Menu</li>
<li>Contact</li>
</ul>
</header>
<div class="menu-grid">
<div class="restaurant-info">
<h1>Example Pizzeria</h1>
</div>
<div class="table-of-contents">
<h2>Menu</h2>
<form id="search-form">
<input id="search-input" type="search" placeholder="Or search for an item..." />
</form>
<h3 class="menu-section"><a id="appetizers-link" href="#appetizers">Appetizers</a></h3>
<h3 class="menu-section"><a id="rolls-calzones-link" href="#rolls-calzones">Rolls & Calzones</a></h3>
<h3 class="menu-section"><a id="pizza-link" href="#pizza">Pizza</a></h3>
<h3 class="menu-section"><a id="salads-link" href="#salads">Salads</a></h3>
<h3 class="menu-section"><a id="pasta-link" href="#pasta">Pasta</a></h3>
<h3 class="menu-section"><a id="sandwiches-link" href="#sandwiches">Sandwiches</a></h3>
</div>
<div class="inner-menu-grid">
<h2 id="appetizers" class="food-section">Appetizers</h2>
<div class="menu-item">
<div class="food-item">
<span class="name-of-food">Zucchini Sticks</span>
<p class="food-description">Served with marinara sauce</p>
</div>
<div class="price">
$6.95
</div>
</div>
<div class="menu-item">
<div class="food-item">
<span class="name-of-food">Stuffed Mushrooms</span>
</div>
<div class="price">
$6.95
</div>
</div>
<div class="menu-item">
<div class="food-item">
<span class="name-of-food"> Mozzarella Sticks (5)</span>
<p class="food-description">Served with marinara sauce</p>
</div>
<div class="price">
$7.50
</div>
</div>
<div class="menu-item">
<div class="food-item">
<span class="name-of-food">Baked Clams</span>
</div>
<div class="price">
$8.96
</div>
</div>
<div class="menu-item">
<div class="food-item">
<span class="name-of-food">Mozarella Caprese</span>
<p class="food-description">Fresh mozzarella, tomatores, basil, olive oil & balsamic vinegar</p>
</div>
<div class="price">
$7.50
</div>
</div>
<div class="menu-item">
<div class="food-item">
<span class="name-of-food">Mozzarella Sticks (5)</span>
</div>
<div class="price">
$7.50
</div>
</div>
<h2 id="rolls-calzones" class="food-section">Rolls and Calzones</h2>
<div class="menu-item">
<div class="food-item">
<span class="name-of-food">Chicken Roll</span>
</div>
<div class="price">
$6.95
</div>
</div>
<div class="menu-item">
<div class="food-item">
<span class="name-of-food">Buffalo Chcicken Roll</span>
</div>
<div class="price">
$6.95
</div>
</div>
<div class="menu-item">
<div class="food-item">
<span class="name-of-food">Spinahc Roll</span>
</div>
<div class="price">
$6.95
</div>
</div>
<div class="menu-item">
<div class="food-item">
<span class="name-of-food">Sausage Roll</span>
</div>
<div class="price">
$6.95
</div>
</div>
<div class="menu-item">
<div class="food-item">
<span class="name-of-food">Chicken and Broccoli Roll</span>
</div>
<div class="price">
$6.95
</div>
</div>
<h2 id="pizza" class="food-section">Pizza</h2>
<div class="menu-item">
<div class="food-item">
<span class="name-of-food">Zucchini Sticks</span>
<p class="food-description">Served with marinara sauce</p>
</div>
<div class="price">
$6.95
</div>
</div>
<div class="menu-item">
<div class="food-item">
<span class="name-of-food">Stuffed Mushrooms</span>
</div>
<div class="price">
$6.95
</div>
</div>
<div class="menu-item">
<div class="food-item">
<span class="name-of-food"> Mozzarella Sticks (5)</span>
<p class="food-description">Served with marinara sauce</p>
</div>
<div class="price">
$7.50
</div>
</div>
<div class="menu-item">
<div class="food-item">
<span class="name-of-food">Baked Clams</span>
</div>
<div class="price">
$8.96
</div>
</div>
<div class="menu-item">
<div class="food-item">
<span class="name-of-food">Mozarella Caprese</span>
<p class="food-description">Fresh mozzarella, tomatores, basil, olive oil & balsamic vinegar</p>
</div>
<div class="price">
$7.50
</div>
</div>
<div class="menu-item">
<div class="food-item">
<span class="name-of-food">Mozzarella Sticks (5)</span>
</div>
<div class="price">
$7.50
</div>
</div>
<h2 id="salads" class="food-section">Salads</h2>
<div class="menu-item">
<div class="food-item">
<span class="name-of-food">Chicken Roll</span>
</div>
<div class="price">
$6.95
</div>
</div>
<div class="menu-item">
<div class="food-item">
<span class="name-of-food">Buffalo Chcicken Roll</span>
</div>
<div class="price">
$6.95
</div>
</div>
<div class="menu-item">
<div class="food-item">
<span class="name-of-food">Spinahc Roll</span>
</div>
<div class="price">
$6.95
</div>
</div>
<div class="menu-item">
<div class="food-item">
<span class="name-of-food">Sausage Roll</span>
</div>
<div class="price">
$6.95
</div>
</div>
<div class="menu-item">
<div class="food-item">
<span class="name-of-food">Chicken and Broccoli Roll</span>
</div>
<div class="price">
$6.95
</div>
</div>
<h2 id="pasta" class="food-section">Pasta</h2>
<div class="menu-item">
<div class="food-item">
<span class="name-of-food">Pasta item</span>
</div>
<div class="price">
$6.95
</div>
</div>
<div class="menu-item">
<div class="food-item">
<span class="name-of-food">Buffalo Chcicken Roll</span>
</div>
<div class="price">
$6.95
</div>
</div>
<div class="menu-item">
<div class="food-item">
<span class="name-of-food">Spinahc Roll</span>
</div>
<div class="price">
$6.95
</div>
</div>
<div class="menu-item">
<div class="food-item">
<span class="name-of-food">Sausage Roll</span>
</div>
<div class="price">
$6.95
</div>
</div>
<div class="menu-item">
<div class="food-item">
<span class="name-of-food">Chicken and Broccoli Roll</span>
</div>
<div class="price">
$6.95
</div>
</div>
<h2 id="sandwiches" class="food-section">Sandwiches</h2>
<div class="menu-item">
<div class="food-item">
<span class="name-of-food">Chicken Roll</span>
</div>
<div class="price">
$6.95
</div>
</div>
<div class="menu-item">
<div class="food-item">
<span class="name-of-food">Buffalo Chcicken Roll</span>
</div>
<div class="price">
$6.95
</div>
</div>
<div class="menu-item">
<div class="food-item">
<span class="name-of-food">Spinahc Roll</span>
</div>
<div class="price">
$6.95
</div>
</div>
<div class="menu-item">
<div class="food-item">
<span class="name-of-food">Sausage Roll</span>
</div>
<div class="price">
$6.95
</div>
</div>
<div class="menu-item">
<div class="food-item">
<span class="name-of-food">Chicken and Broccoli Roll</span>
</div>
<div class="price">
$6.95
</div>
</div>
</div>
<!--close .inner-menu-grid-->
</div>
<!--close .menu-grid-->
View on JSFiddle

Create a grid with two rows, put the navigation bar in the top row, and put your content in your second row, and make sure that the first row starts at the top and finishes 150px from the top.

You might find position:sticky helpful.
It seems you are already using it for the "Table of Contents" section.
A stickily positioned element is an element whose computed position value is sticky. It's treated as relatively positioned until its containing block crosses a specified threshold (such as setting top to value other than auto) within its flow root (or the container it scrolls within), at which point it is treated as "stuck" until meeting the opposite edge of its containing block. -- position.
Also note browser compatibility for position:sticky.
* {
box-sizing: border-box;
padding: 0;
margin: 0;
}
ul {
margin: 0;
padding: 0;
list-style: none;
}
h2,
h3,
a {
color: #34495e;
}
a {
text-decoration: none;
}
.logo {
margin: 0;
font-size: 1.45em;
}
.main-nav {
margin-top: 5px;
}
.logo a,
.main-nav a {
padding: 10px 15px;
text-transform: uppercase;
text-align: center;
display: block;
}
.main-nav a {
color: #34495e;
font-size: .99em;
}
.main-nav a:hover {
color: #718daa;
}
.header {
height: 150px;
padding-top: .5em;
padding-bottom: .5em;
border: 1px solid #a2a2a2;
background-color: #f4f4f4;
-webkit-box-shadow: 0px 0px 14px 0px rgba(0, 0, 0, 0.75);
-moz-box-shadow: 0px 0px 14px 0px rgba(0, 0, 0, 0.75);
box-shadow: 0px 0px 14px 0px rgba(0, 0, 0, 0.75);
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
width: 100vw;
position: sticky;
top: 0;
z-index: 1;
}
/* =================================
Media Queries
==================================== */
#media (min-width: 769px) {
.header,
.main-nav {
display: flex;
}
.header {
flex-direction: column;
align-items: center;
.header {
width: 80%;
margin: 0 auto;
max-width: 1150px;
}
}
}
#media (min-width: 1025px) {
.header {
flex-direction: row;
justify-content: space-between;
}
}
.parallex {
background: url("https://scontent-lga3-1.xx.fbcdn.net/v/t31.0-8/277233_456825154330649_1101536084_o.jpg?_nc_cat=106&_nc_ht=scontent-lga3-1.xx&oh=a23cf28b01ae96e2585b36164a747906&oe=5D567AAB") no-repeat center bottom /cover;
background-attachment: fixed;
height: 100vh;
}
.text-in-parallex {
position: relative;
top: 70vh;
left: 28vw;
color: white;
font-size: 45px;
}
body {
background-color: #EEEEEE;
/* #EE2324 */
}
.menu-grid {
display: grid;
grid-template-columns: 1fr 3fr;
width: 80%;
margin: 20px auto 100px auto;
padding-bottom: 100px;
border: 1px solid lightgray;
background-color: white;
border-radius: 3px;
/* Shadow */
-moz-box-shadow: 0px 3px 30px 1px #ccc;
-webkit-box-shadow: 0px 3px 30px 1px #ccc;
box-shadow: 10px 15px 30px 15px #ccc;
font-family: 'Alice', serif;
}
.table-of-contents {
padding: 20px;
position: sticky;
top: 0;
height: 100vh;
}
.table-of-contents>h2 {
text-align: center;
margin-bottom: 10px;
}
.inner-menu-grid {
display: grid;
grid-template-columns: 1fr 1fr;
grid-gap: 20px;
background-color: white;
padding: 20px 20px 25px 20px;
border-radius: 3px;
}
.menu-item {
display: flex;
justify-content: space-between;
}
.price {
font-size: 20px;
}
.menu-section {
font-family: "Open Sans", Arial, sans-serif;
font-size: 20.9368px;
font-weight: 400;
margin-bottom: 10px;
}
.menu-section>a {
text-decoration: none;
color: #999999;
padding-left: 7px;
}
.menu-section>a:hover {
border-left: 1px solid blue;
color: #1f5ea9;
text-decoration: underline;
}
.name-of-food {
font-size: 20px;
}
.food-description {
color: grey;
font-style: italic;
}
.food-section {
grid-column: 1 / 3;
text-align: center;
padding-top: 20px;
font-size: 2em;
}
.food-section:nth-child(1) {
padding-top: 0;
}
.restaurant-info {
grid-column: 1 / 3;
text-align: center;
border: 1px solid lightgray;
padding: 20px 0px;
}
#search-form {
border-radius: 3px;
text-align: center;
margin-bottom: 10px;
}
#search-input {
width: 80%;
}
.fab {
padding: 10px;
font-size: 30px;
text-align: center;
text-decoration: none;
margin: 5px 2px;
border-radius: 3px;
}
.fab:hover {
opacity: 0.7;
cursor: pointer;
}
.fa-facebook-square {
background: #3B5998;
color: white;
}
<header class="header">
<h1 class="logo">Flexbox</h1>
<ul class="main-nav">
<li>Menu</li>
<li>Contact</li>
</ul>
</header>
<div class="menu-grid">
<div class="restaurant-info">
<h1>Example Pizzeria</h1>
</div>
<div class="table-of-contents">
<h2>Menu</h2>
<form id="search-form">
<input id="search-input" type="search" placeholder="Or search for an item..." />
</form>
<h3 class="menu-section"><a id="appetizers-link" href="#appetizers">Appetizers</a></h3>
<h3 class="menu-section"><a id="rolls-calzones-link" href="#rolls-calzones">Rolls & Calzones</a></h3>
<h3 class="menu-section"><a id="pizza-link" href="#pizza">Pizza</a></h3>
<h3 class="menu-section"><a id="salads-link" href="#salads">Salads</a></h3>
<h3 class="menu-section"><a id="pasta-link" href="#pasta">Pasta</a></h3>
<h3 class="menu-section"><a id="sandwiches-link" href="#sandwiches">Sandwiches</a></h3>
</div>
<div class="inner-menu-grid">
<h2 id="appetizers" class="food-section">Appetizers</h2>
<div class="menu-item">
<div class="food-item">
<span class="name-of-food">Zucchini Sticks</span>
<p class="food-description">Served with marinara sauce</p>
</div>
<div class="price">
$6.95
</div>
</div>
<div class="menu-item">
<div class="food-item">
<span class="name-of-food">Stuffed Mushrooms</span>
</div>
<div class="price">
$6.95
</div>
</div>
<div class="menu-item">
<div class="food-item">
<span class="name-of-food"> Mozzarella Sticks (5)</span>
<p class="food-description">Served with marinara sauce</p>
</div>
<div class="price">
$7.50
</div>
</div>
<div class="menu-item">
<div class="food-item">
<span class="name-of-food">Baked Clams</span>
</div>
<div class="price">
$8.96
</div>
</div>
<div class="menu-item">
<div class="food-item">
<span class="name-of-food">Mozarella Caprese</span>
<p class="food-description">Fresh mozzarella, tomatores, basil, olive oil & balsamic vinegar</p>
</div>
<div class="price">
$7.50
</div>
</div>
<div class="menu-item">
<div class="food-item">
<span class="name-of-food">Mozzarella Sticks (5)</span>
</div>
<div class="price">
$7.50
</div>
</div>
<h2 id="rolls-calzones" class="food-section">Rolls and Calzones</h2>
<div class="menu-item">
<div class="food-item">
<span class="name-of-food">Chicken Roll</span>
</div>
<div class="price">
$6.95
</div>
</div>
<div class="menu-item">
<div class="food-item">
<span class="name-of-food">Buffalo Chcicken Roll</span>
</div>
<div class="price">
$6.95
</div>
</div>
<div class="menu-item">
<div class="food-item">
<span class="name-of-food">Spinahc Roll</span>
</div>
<div class="price">
$6.95
</div>
</div>
<div class="menu-item">
<div class="food-item">
<span class="name-of-food">Sausage Roll</span>
</div>
<div class="price">
$6.95
</div>
</div>
<div class="menu-item">
<div class="food-item">
<span class="name-of-food">Chicken and Broccoli Roll</span>
</div>
<div class="price">
$6.95
</div>
</div>
<h2 id="pizza" class="food-section">Pizza</h2>
<div class="menu-item">
<div class="food-item">
<span class="name-of-food">Zucchini Sticks</span>
<p class="food-description">Served with marinara sauce</p>
</div>
<div class="price">
$6.95
</div>
</div>
<div class="menu-item">
<div class="food-item">
<span class="name-of-food">Stuffed Mushrooms</span>
</div>
<div class="price">
$6.95
</div>
</div>
<div class="menu-item">
<div class="food-item">
<span class="name-of-food"> Mozzarella Sticks (5)</span>
<p class="food-description">Served with marinara sauce</p>
</div>
<div class="price">
$7.50
</div>
</div>
<div class="menu-item">
<div class="food-item">
<span class="name-of-food">Baked Clams</span>
</div>
<div class="price">
$8.96
</div>
</div>
<div class="menu-item">
<div class="food-item">
<span class="name-of-food">Mozarella Caprese</span>
<p class="food-description">Fresh mozzarella, tomatores, basil, olive oil & balsamic vinegar</p>
</div>
<div class="price">
$7.50
</div>
</div>
<div class="menu-item">
<div class="food-item">
<span class="name-of-food">Mozzarella Sticks (5)</span>
</div>
<div class="price">
$7.50
</div>
</div>
<h2 id="salads" class="food-section">Salads</h2>
<div class="menu-item">
<div class="food-item">
<span class="name-of-food">Chicken Roll</span>
</div>
<div class="price">
$6.95
</div>
</div>
<div class="menu-item">
<div class="food-item">
<span class="name-of-food">Buffalo Chcicken Roll</span>
</div>
<div class="price">
$6.95
</div>
</div>
<div class="menu-item">
<div class="food-item">
<span class="name-of-food">Spinahc Roll</span>
</div>
<div class="price">
$6.95
</div>
</div>
<div class="menu-item">
<div class="food-item">
<span class="name-of-food">Sausage Roll</span>
</div>
<div class="price">
$6.95
</div>
</div>
<div class="menu-item">
<div class="food-item">
<span class="name-of-food">Chicken and Broccoli Roll</span>
</div>
<div class="price">
$6.95
</div>
</div>
<h2 id="pasta" class="food-section">Pasta</h2>
<div class="menu-item">
<div class="food-item">
<span class="name-of-food">Pasta item</span>
</div>
<div class="price">
$6.95
</div>
</div>
<div class="menu-item">
<div class="food-item">
<span class="name-of-food">Buffalo Chcicken Roll</span>
</div>
<div class="price">
$6.95
</div>
</div>
<div class="menu-item">
<div class="food-item">
<span class="name-of-food">Spinahc Roll</span>
</div>
<div class="price">
$6.95
</div>
</div>
<div class="menu-item">
<div class="food-item">
<span class="name-of-food">Sausage Roll</span>
</div>
<div class="price">
$6.95
</div>
</div>
<div class="menu-item">
<div class="food-item">
<span class="name-of-food">Chicken and Broccoli Roll</span>
</div>
<div class="price">
$6.95
</div>
</div>
<h2 id="sandwiches" class="food-section">Sandwiches</h2>
<div class="menu-item">
<div class="food-item">
<span class="name-of-food">Chicken Roll</span>
</div>
<div class="price">
$6.95
</div>
</div>
<div class="menu-item">
<div class="food-item">
<span class="name-of-food">Buffalo Chcicken Roll</span>
</div>
<div class="price">
$6.95
</div>
</div>
<div class="menu-item">
<div class="food-item">
<span class="name-of-food">Spinahc Roll</span>
</div>
<div class="price">
$6.95
</div>
</div>
<div class="menu-item">
<div class="food-item">
<span class="name-of-food">Sausage Roll</span>
</div>
<div class="price">
$6.95
</div>
</div>
<div class="menu-item">
<div class="food-item">
<span class="name-of-food">Chicken and Broccoli Roll</span>
</div>
<div class="price">
$6.95
</div>
</div>
</div>
<!--close .inner-menu-grid-->
</div>
<!--close .menu-grid-->

I'd suggest that if you don't want content to be occluded by the header, position: fixed may not be the best solution. Another approach would be to layout the page so that the header has a fixed height, then the content below takes up the rest of the page height, with overflow set to auto, so that it will scroll but the header won't.
Quick example:
<main>
<header>...</header>
<div class="content">...</div>
</main>
body, html {
height: 100%;
}
main {
display: flex;
flex-direction: column;
height: 100%;
}
header {
height: 200px;
flex: 0 0 auto;
}
.content {
flex: 1;
overflow: auto;
}

Related

I'd like to have the same design with my background-color circle using bootstrap 5 when i will pass on mobile size

I'm designing a card with a color background instead of image, after passing in mobile size (sm or xs) my rounded-circle background-color changes to an ellipsoid's one.
Here is what I want:
I would like to have the same design for xl-md-sm even for xs, I used #mediaquery to try to resolve this problem unfortunately it didn't work. so I want your help.
This is what I get:
Here is HTML markup:
<div class="container mt-5 mb-4 px-5">
<div class="card ">
<div class="row mt-5 w-100 hover-shadow ">
<div class="meq card-body bg-danger .d-sm-flex col-2 mt-0 mb-0 rounded-circle px-sm-0 ">
<h1 class="nowrap text-center text-light font-weight-bold px-sm-2 py-5">KKE</h1>
<a href="#!">
</a>
</div>
<div class="col-10 second_part">
<div class="card-text justify-content-center align-items-center">
<div class="card-body">
<a href="#" class="list-group-item-action">
<div class="d-flex w-100 justify-content-between">
<h3 class="mb-1 text-dark font-weight-bold">Kumbu<br> Kumbu<br>Ezechias</h3>
<small class="text-muted">
<ul class="list-group">
<li>
<div class="progress ">
<div class=" progress-bar bg-danger" role="progressbar" style="width: 100%;"
aria-valuenow="100" aria-valuemin="100" aria-valuemax="100"></div>
</div>
</li>
<li> Dear you won</li>
<li><small class="font-weight-bold align-content-center float-right">Mo 20224525</small>
</li>
</ul>
</small>
</div>
<p class="mb-1">
Xxxxx77
</p>
<p class="mb-1">
04:25
</p>
</a>
</div>
</div>
</div>
</div>
</div>
<!--/ card 1 -->
here is CSS
* {
margin: 0;
padding: 0;
initial-letter-align: center;
text-decoration: none;
box-sizing: border-box;
}
h1,
h3,
h6 {
text-transform: uppercase;
}
ul {
margin-left: -10px;
padding-left: -10px;
list-style: none;
}
h6 {
text-align: end;
margin-top: 70%;
margin-right: 37%;
}
.nowrap {
white-space: nowrap;
}
#media (max-width: 48em) {
h1,
h3 {
font-size: small;
font-weight: normal;
}
h1 {
margin-top: 0%;
text-align: center;
}
div .meq {
top: 50%;
text-align: center;
max-height: 10.1rem;
max-width: 10.1rem;
padding-left: 0.7rem;
padding-right: 1.9rem;
position: relative;
border-radius: 100%;
}
* {
margin: 0;
padding: 0;
initial-letter-align: center;
text-decoration: none;
box-sizing: border-box;
}
}
I think what's making the trouble is when you use classes .d-sm-flex and card-body that are making trouble.
Here is what I suggest you for your circle div
<div class="rounded-circle text-center" style="width: 10rem; height: 10rem; background: red;" >
<h1 class="nowrap text-center text-light font-weight-bold px-sm-2 py-5">KKE</h1>
<a href="#!">
</a>
</div>

How to lock scroll snap one direction at a time?

I have created a calendar that displays each day in a column, and each day has multiple rows. I also added scroll snap to the grid. So the user can swipe horizontally to view each day. However due to the number of rows under the days, swiping (mobile) moves in both directions (vertically and horizontally). I'd like it to lock the swipe to go one direction at a time. So when the user swipes horizontally, the days move, once the day grid snaps in place, they can scroll vertically, or horizontally if they like. Here is my demo: https://codepen.io/starkana/pen/YzzBgPN
CSS & HTML
*,
:after,
:before {
box-sizing: border-box;
padding: 0;
margin: 0;
}
html {
font-size: 62.5%;
}
body {
color: #384ad2;
-moz-osx-font-smoothing: grayscale;
-webkit-font-smoothing: antialiased;
font-size: 1.6rem;
height: 100%;
font-family: arial;
}
a {
text-decoration: none;
color: inherit;
}
body {
background: #ccc;
}
.calendar {
max-height: 100vh;
max-width: 100vh;
display: grid;
grid-template-columns: repeat(9, 80vw);
grid-column-gap: 20px;
scroll-snap-type: x mandatory;
padding-left: 5vw;
transition: transform 0.2s ease-in-out;
overflow-x: scroll;
justify-content: left;
}
.day {
margin-bottom: 100px;
min-width: 0;
scroll-snap-align: center;
}
.day h2 {
font-size: 1.5rem;
font-weight: 900;
letter-spacing: 0.1rem;
text-align: left;
text-transform: uppercase;
margin: 1rem 0;
}
.cards {
display: grid;
grid-row-gap: 6px;
grid-column-gap: 24px;
grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
justify-content: center;
min-width: 0;
}
.card {
background: #fff;
border-radius: 5px;
box-shadow: 0 4px 6px rgba(49, 54, 68, 0.05),
0 5px 20px rgba(49, 54, 68, 0.08);
max-height: 65px;
margin-bottom: 24px;
position: relative;
transition: box-shadow 0.6s ease, color 0.2s ease,
transform 0.2s ease-in-out;
}
.card:hover {
box-shadow: 0 4px 6px rgba(138, 155, 198, 0.05),
0 5px 25px rgba(82, 112, 194, 0.15);
}
.card:hover .highlighter {
opacity: 1;
}
.card a {
display: grid;
grid-template-columns: 50px auto;
}
.content {
padding: 10px 14px;
position: relative;
border: 1px solid red;
min-width: 0;
}
.title {
font-size: 1.4rem;
font-weight: 800;
overflow: hidden;
padding-bottom: 3px;
text-overflow: ellipsis;
white-space: nowrap;
}
.airing {
font-size: 1.3rem;
font-weight: 600;
opacity: 0.9;
}
.next,
.now {
background: blue;
border-radius: 4px;
top: -14px;
color: white;
font-size: 1.1rem;
font-weight: 800;
padding: 3px 8px;
position: absolute;
right: -12px;
}
.image {
border-radius: 4px 0 0 4px;
height: 100%;
max-height: 65px;
object-fit: cover;
object-position: center;
transition: opacity 0.3s;
width: 100%;
}
<div class="calendar">
<div class="day">
<h2>Monday</h2>
<div class="cards">
<div class="card">
<a href="#">
<img
src="/app/static/img/covers/large/12903-RSbXdLBGyI.jpg"
class="image"
/>
<div class="content">
<div class="title">Title</div>
<div class="airing">Subtitle</div>
</div>
</a>
</div>
<div class="card">
<a href="#">
<img
src="/app/static/img/covers/large/12903-RSbXdLBGyI.jpg"
class="image"
/>
<div class="content">
<div class="title">Title</div>
<div class="airing">Subtitle</div>
</div>
</a>
</div>
<div class="card">
<a href="#">
<img
src="/app/static/img/covers/large/12903-RSbXdLBGyI.jpg"
class="image"
/>
<div class="content">
<div class="title">Title</div>
<div class="airing">Subtitle</div>
</div>
</a>
</div>
<div class="card">
<a href="#">
<img
src="/app/static/img/covers/large/12903-RSbXdLBGyI.jpg"
class="image"
/>
<div class="content">
<div class="title">Title</div>
<div class="airing">Subtitle</div>
</div>
</a>
</div>
<div class="card">
<a href="#">
<img
src="/app/static/img/covers/large/12903-RSbXdLBGyI.jpg"
class="image"
/>
<div class="content">
<div class="title">Title</div>
<div class="airing">Subtitle</div>
</div>
</a>
</div>
<div class="card">
<a href="#">
<img
src="/app/static/img/covers/large/12903-RSbXdLBGyI.jpg"
class="image"
/>
<div class="content">
<div class="title">Title</div>
<div class="airing">Subtitle</div>
</div>
</a>
</div>
</div>
</div>
<div class="day">
<h2>Monday</h2>
<div class="cards">
<div class="card">
<a href="#">
<img
src="/app/static/img/covers/large/12903-RSbXdLBGyI.jpg"
class="image"
/>
<div class="content">
<div class="title">Title</div>
<div class="airing">Subtitle</div>
</div>
</a>
</div>
</div>
</div>
<div class="day">
<h2>Monday</h2>
<div class="cards">
<div class="card">
<a href="#">
<img
src="/app/static/img/covers/large/12903-RSbXdLBGyI.jpg"
class="image"
/>
<div class="content">
<div class="title">Title</div>
<div class="airing">Subtitle</div>
</div>
</a>
</div>
</div>
</div>
<div class="day">
<h2>Monday</h2>
<div class="cards">
<div class="card">
<a href="#">
<img
src="/app/static/img/covers/large/12903-RSbXdLBGyI.jpg"
class="image"
/>
<div class="content">
<div class="title">Title</div>
<div class="airing">Subtitle</div>
</div>
</a>
</div>
<div class="card">
<a href="#">
<img
src="/app/static/img/covers/large/12903-RSbXdLBGyI.jpg"
class="image"
/>
<div class="content">
<div class="title">Title</div>
<div class="airing">Subtitle</div>
</div>
</a>
</div>
<div class="card">
<a href="#">
<img
src="/app/static/img/covers/large/12903-RSbXdLBGyI.jpg"
class="image"
/>
<div class="content">
<div class="title">Title</div>
<div class="airing">Subtitle</div>
</div>
</a>
</div>
<div class="card">
<a href="#">
<img
src="/app/static/img/covers/large/12903-RSbXdLBGyI.jpg"
class="image"
/>
<div class="content">
<div class="title">Title</div>
<div class="airing">Subtitle</div>
</div>
</a>
</div>
<div class="card">
<a href="#">
<img
src="/app/static/img/covers/large/12903-RSbXdLBGyI.jpg"
class="image"
/>
<div class="content">
<div class="title">Title</div>
<div class="airing">Subtitle</div>
</div>
</a>
</div>
<div class="card">
<a href="#">
<img
src="/app/static/img/covers/large/12903-RSbXdLBGyI.jpg"
class="image"
/>
<div class="content">
<div class="title">Title</div>
<div class="airing">Subtitle</div>
</div>
</a>
</div>
<div class="card">
<a href="#">
<img
src="/app/static/img/covers/large/12903-RSbXdLBGyI.jpg"
class="image"
/>
<div class="content">
<div class="title">Title</div>
<div class="airing">Subtitle</div>
</div>
</a>
</div>
<div class="card">
<a href="#">
<img
src="/app/static/img/covers/large/12903-RSbXdLBGyI.jpg"
class="image"
/>
<div class="content">
<div class="title">Title</div>
<div class="airing">Subtitle</div>
</div>
</a>
</div>
<div class="card">
<a href="#">
<img
src="/app/static/img/covers/large/12903-RSbXdLBGyI.jpg"
class="image"
/>
<div class="content">
<div class="title">Title</div>
<div class="airing">Subtitle</div>
</div>
</a>
</div>
<div class="card">
<a href="#">
<img
src="/app/static/img/covers/large/12903-RSbXdLBGyI.jpg"
class="image"
/>
<div class="content">
<div class="title">Title</div>
<div class="airing">Subtitle</div>
</div>
</a>
</div>
</div>
</div>
<div class="day">
<h2>Monday</h2>
<div class="cards">
<div class="card">
<a href="#">
<img
src="/app/static/img/covers/large/12903-RSbXdLBGyI.jpg"
class="image"
/>
<div class="content">
<div class="title">Title</div>
<div class="airing">Subtitle</div>
</div>
</a>
</div>
</div>
</div>
</div>

Page overflowing from the right margin

This is my css code.
nav.navbar {
color: white !important;
background-color: #d82c2e;
font-weight: bold;
}
html {
margin-right: 70px !important;
}
.introSec {
height: 750px;
}
.hr {
width: 100px;
border-top: 1px solid red;
}
.navbar-flat li a:focus,
.navbar-flat li a:hover,
.navbar-flat li.active a,
.navbar-brand {
background-color: #c12728;
color: #fff;
}
.navbar-flat a {
transition: all .3s ease-in, 1s;
}
nav.navbar {
padding-left: 35%;
}
.nav-link {
color: #fff;
/*font-size:calc(15px + 0.6vw);*/
}
.navbar-brand {
color: white;
}
.introLine {
text-align: center;
padding-top: 30px;
font-size: calc(15px + 0.6vw);
}
.pieImage {
border-radius: 100%;
margin: 40px 45%;
height: calc(20% + 0.6vw);
min-width: calc(13% + 0.6vw);
}
.pieImage2 {
border-radius: 100%;
margin-top: 20px;
width: 300px !important;
height: 600;
display: inline-block;
}
.coolOne {
margin-left: 17%;
}
#landing-header {
margin-top: -80px;
}
.myName {
text-align: center;
color: white;
font-family: Lato, sans-serif;
letter-spacing: -2px;
}
.title {
text-align: center;
color: black;
word-spacing: 3px;
padding: 10px;
margin: 15px auto;
font-family: 'Pontano Sans', sans-serif;
font-size: calc(30px + 0.6vw);
}
.firstSec {
background-color: #d82c2e;
height: 725px;
}
.aboutTitle {
text-align: center;
color: #d82c2e;
font-family: Lato, sans-serif;
font-weight: 700;
font-size: 30px;
}
.firstSec {
margin-top: 57px;
}
.aboutIntro {
text-align: center;
font-family: Lato, sans-serif;
}
.aboutMe {
padding: 20px 90px 0 90px;
}
.activities-inner {
padding-top: 50px;
margin: 50px;
width: 100%;
}
.activities {
border: 1px solid #e3e5e5;
display: inline;
padding: 50px;
}
.column {
float: left;
width: 25%;
border: 1px solid lightgray;
height: 200px;
text-align: center;
}
.row:after {
content: "";
display: table;
clear: both;
}
.column {
font-weight: 500;
font-size: 30px;
padding-top: 30px;
}
.icon {
font-size: 40px;
color: #d82c2e;
}
.technicalSkills {
text-align: center;
font-family: Lato, sans-serif;
}
.thirdSec {
background-color: #d82c2e;
}
.technicalSkills {
margin-top: 50px;
color: white;
padding-top: 20px;
}
.portfolioHeading {
text-align: center;
color: #d82c2e;
font-weight: 700;
font-family: 700;
font-size: 30px;
}
.hr {
margin-top: 20px;
color: #d82c2e;
}
.portfolioPic {
margin: 20px 35%;
width: 30%;
}
.text-center {
display: flex;
flex-wrap: wrap;
}
.lastHr {
float: left;
}
.contact {
text-align: center;
}
.lastSec {
background-color: #d82c2e;
margin-top: 20px;
}
.contactDetails {
padding-top: 20px;
}
.white {
color: white;
}
.space {
padding-top: 5px;
}
.row {
padding-left: 100px;
padding-right: 130px;
}
.dev {
font-size: calc(18px + 1.0vw);
}
.secondDev {
font-size: calc(15px + 0.6vw);
}
#landing-header {
z-index: 1;
position: relative;
text-align: center;
padding-top: 40vh;
}
#landing-header h1 {
color: #fff;
}
.slideshow {
position: inherit;
width: 100%;
height: 100%;
top: 0;
left: 0;
z-index: 0;
list-style: none;
margin: 0;
margin-top: -23.1%;
padding: 0;
}
.slideshow li {
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 0;
background-size: cover;
background-position: 50% 50%;
background-repeat: no-repeat;
opacity: 0;
z-index: 0;
animation: imageAnimation 50s linear infinite;
}
.slideshow li:nth-child(1) {
background-image: url(https://bearlake.org/wp-
content/uploads/cache/images/garden-city-logan-campgrounds/garden-city-logan-campgrounds-987998613.jpg)
}
.slideshow li:nth-child(2) {
background-image: url(https://bearlake.org/wp-content/uploads/cache/images/garden-city-logan-campgrounds/garden-city-logan-campgrounds-987998613.jpg);
animation-delay: 10s;
}
.slideshow li:nth-child(3) {
background-image: url(https://bearlake.org/wp-content/uploads/cache/images/garden-city-logan-campgrounds/garden-city-logan-campgrounds-987998613.jpg);
animation-delay: 20s;
}
.slideshow li:nth-child(4) {
background-image: url(https://bearlake.org/wp-content/uploads/cache/images/garden-city-logan-campgrounds/garden-city-logan-campgrounds-987998613.jpg);
animation-delay: 30s;
}
.slideshow li:nth-child(5) {
background-image: url(https://bearlake.org/wp-content/uploads/cache/images/garden-city-logan-campgrounds/garden-city-logan-campgrounds-987998613.jpg);
animation-delay: 40s;
}
#keyframes imageAnimation {
0% {
opacity: 0;
animation-timing-function: ease-in;
}
10% {
opacity: 1;
animation-timing-function: ease-out;
}
20% {
opacity: 1
}
30% {
opacity: 0
}
}
.no-cssanimations .slideshow li {
opacity: 1;
}
.nav-link {
color: white !important;
}
.navbar-toggler {
border-color: white;
/*margin-left: -50%;*/
}
.navbar-fixed-top {
top: 0;
}
.navbar-light .navbar-toggler {
border-color: transparent !important;
}
<div class="row">
<div class="column col-lg-3 col-md-6 col-sm-12">
<p class="icon">
<i class="fas fa-code"> </i> </p>
<h3 class="dev"> DEVELOPMENT </h3>
</div>
<div class="column col-lg-3 col-md-6 col-sm-12">
<p class="icon">
<i class="fas fa-music"></i>
</p>
<h3 class="dev"> MUSIC </h3>
</div>
<div class="column col-lg-3 col-md-6 col-sm-12">
<p class="icon">
<i class="fas fa-basketball-ball"></i>
</p>
<h3 class="dev"> TENNIS </h3>
</div>
<div class="column col-lg-3 col-md-6 col-sm-12">
<p class="icon">
<i class="fas fa-book"></i>
</p>
<h3 class="dev"> BOOKS </h3>
</div>
</div>
</div>
<div id="scrollToThird">
</section>
<!-- Third Sec Starts here -->
<section class="thirdSec">
<h2 class="technicalSkills"> TECHNICAL SKILLS </h2>
<div id="carouselExampleIndicators" class="carousel slide" data-ride="carousel">
<ol id="scrollToFourth" class="carousel-indicators">
<li data-target="#carouselExampleIndicators" data-slide-to="0" class="active"></li>
<li data-target="#carouselExampleIndicators" data-slide-to="1"></li>
</ol>
<div class="carousel-inner">
<div class="carousel-item active coolOne">
<img class="pieImage2 col-lg-4 col-md-4 col-sm-12" src="./htmlPercent2.jpg">
<img class="pieImage2 col-lg-4 col-md-4 col-sm-12" src="./cssPercent2.jpg">
<img class="pieImage2 col-lg-4 col-md-4 col-sm-12" src="./javascriptPercent2.jpg">
</div>
<div class="carousel-item coolOne">
<img class="pieImage2 col-lg-4 col-md-4 col-sm-12" src="./nodejsPercent2.jpg">
<img class="pieImage2 col-lg-4 col-md-4 col-sm-12" src="./expressPercent2.jpg">
<img class="pieImage2 col-lg-4 col-md-4 col-sm-12" src="./javascriptPercent2.jpg">
</div>
</div>
<a class="carousel-control-prev" href="#carouselExampleIndicators" role="button" data-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="carousel-control-next" href="#carouselExampleIndicators" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
</section>
</div>
<section class="fourthSec">
<hr class="hr">
<h2 class="portfolioHeading"> PORTFOLIO </h2>
<div class="container">
<div class="row text-center" style="display:flex; flex-wrap: wrap;">
<div class="col-lg-4 col-md-6">
<div class="img-thumbnail">
<img src="./screencapture-lit-mesa-98519-herokuapp-1518954523255.png" class="img-fluid">
<div class="caption">
<h4 class="secondDev"> Yelp Camp</h4>
</div>
Check it out!
</div>
</div>
<div class="col-lg-4 col-md-6">
<div class="img-thumbnail">
<img src="./screencapture-dry-castle-83141-herokuapp-blogs-1519047247719.png" class="img-fluid">
<div class="caption">
<h4 class="secondDev"> Blog Site</h4>
</div>
Check it out!
</div>
</div>
<div class="col-lg-4 col-md-6">
<div class="img-thumbnail">
<img src="./screencapture-whispering-hamlet-69416-herokuapp-results-1519112901364.png" class="img-fluid">
<div class="caption">
<h4 class="secondDev"> Seach Any Movie</h4>
</div>
Check it out!
</div>
</div>
<div class="space col-lg-4 col-md-6">
<div class="img-thumbnail">
<img src="./IMG_3717.PNG" width="80" class="img-fluid">
<div class="caption">
<h4 class="secondDev"> 101 WeirdFunFacts </h4>
</div>
Check it out!
</div>
</div>
<div class="space col-lg-4 col-md-6">
<div class="img-thumbnail">
<img src="./IMG_3718.PNG" width="80" class="img-fluid">
<div class="caption">
<h4 class="secondDev"> Flash Card</h4>
</div>
Check it out!
</div>
</div>
<div class="space col-lg-4 col-md-6">
<div class="img-thumbnail">
<img src="./IMG_3719.PNG" width="80" class="img-fluid">
<div class="caption">
<h4 class="secondDev"> Algebraic Equations </h4>
</div>
Check it out!
<div id="scrollToFifth">
</div>
</div>
</div>
</div>
</div>
</section>
<section class="lastSec">
<h2 class="contactDetails"> CONTACT DETAILS </h2>
<hr class="col-lg-4 col-md-4 col-sm-4 col-xs-2 lastHr">
<br>
<br>
<div class="contact">
<h5 class="white"> Email: </h5>
<p> —————————————— </p>
<h5 class="white"> Contact Number: </h5>
<p> ——————————— </p>
<h5 class="white"> Address: </h5>
<p> ———————————— </p>
</div>
</section>
<p> assasa </p>
<p> assasa </p>
<p> assasa </p>
<p> assasa </p>
<p> assasa </p>
<p> assasa </p>
<p> assasa </p>
<p> assasa </p>
<p> assasa </p>
<% include partials/footer %>
<% include partials/header %>
<section class="introSec">
<!--<div id="landing-header">-->
<div id="landing-header">
<h1>Hi, I am Neymat Kakar</h1>
<h4> Web/IOS Developer In Dubai </h4>
</div>
<ul class="slideshow">
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
</ul>
</section>
<div id="scrollTo">
<section class="firstSec">
<nav class="navbar navbar-expand-lg navbar-flat navbar-light">
<!--<a class="navbar-brand" href="#srcollTo">HOME </a>-->
<button class="navbar-toggler" type="button" data-toggle="collapse" data-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 mr-auto">
<li class="nav-item">
<a class="nav-link" href="#scrollTo">HOME</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#scrollToSec">ABOUT</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#scrollToThird">SKILLS</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#scrollToFourth">PORTFOLIO</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#scrollToFifth">CONTACT</a>
</li>
</ul>
</div>
</nav>
<img class="pieImage" src="./IMG_8224.jpg">
<h1 class="myName"> NEYMAT KAKAR </h1>
<h3 class="introLine"> CREATIVE - PROFESSIONAL - PASSIONATE</h3>
<h5 class="col-lg-12 col-md-12 col-sm-12 col-xs-12 title"> WEB/IOS APP DEVELOPER</h5>
<div id="scrollToSec">
</section>
</div>
<!-- Second Section Starts Below -->
<section class="secSec">
<hr class="hr">
<h3 class="aboutTitle"> HERE'S WHAT I'M DOING </h3>
<!--<p class = "aboutIntro"> I introduce the most creative and original ideas for my company </p>-->
<p class="aboutMe"> “I am a simple person with great passion for web development. I have been in the field now for quite some time, and have been loving every minute of it. I am also a part-time blogger and avid reader of non-fiction and overall thinker. I also enjoy
going out to local meetups, events and descent clubs to interact with people from various walks of life.” </p>
Please go through the image. This is how my page looks like.
Notice from navbar section, the margin on the right is way out. I need all the sections to have the same margin and the page not to overflow.
I think problem with your html and body margin. Remove margin-right to your html to tag.
Try to set below css
html,body {
width: 100%;
height: 100%;
margin: 0;
padding:0;
overflow-x:hidden;
}
Inside the html if you're using bootstrap go-through about bootstrap container class to get left and right space.

Media carousel in mobile view

I have this code that will display image carousel.
For desktops, I want to display 3 thumbnails per row;
For mobiles, just one or two thumbnail per row horizontally.
The code in working fine in desktopview but in mobileview how do i display in horizontally with only one or two image and use the indicator to see next image ?
i tried using this..but is not working
<div class="col-sm-6 col-md-4">
html
<div class="container">
<div class="row">
<h2>Media Slider Carousel BS3</h2>
</div>
<div class='row'>
<div class='col-md-8'>
<div class="carousel slide media-carousel" id="media">
<div class="carousel-inner">
<div class="item active">
<div class="row">
<div class="col-md-4">
<a class="thumbnail" href="#"><img alt="" src="http://placehold.it/150x150"></a>
</div>
<div class="col-md-4">
<a class="thumbnail" href="#"><img alt="" src="http://placehold.it/150x150"></a>
</div>
<div class="col-md-4">
<a class="thumbnail" href="#"><img alt="" src="http://placehold.it/150x150"></a>
</div>
</div>
</div>
<div class="item">
<div class="row">
<div class="col-md-4">
<a class="thumbnail" href="#"><img alt="" src="http://placehold.it/150x150"></a>
</div>
<div class="col-md-4">
<a class="thumbnail" href="#"><img alt="" src="http://placehold.it/150x150"></a>
</div>
<div class="col-md-4">
<a class="thumbnail" href="#"><img alt="" src="http://placehold.it/150x150"></a>
</div>
</div>
</div>
<div class="item">
<div class="row">
<div class="col-md-4">
<a class="thumbnail" href="#"><img alt="" src="http://placehold.it/150x150"></a>
</div>
<div class="col-md-4">
<a class="thumbnail" href="#"><img alt="" src="http://placehold.it/150x150"></a>
</div>
<div class="col-md-4">
<a class="thumbnail" href="#"><img alt="" src="http://placehold.it/150x150"></a>
</div>
</div>
</div>
</div>
<a data-slide="prev" href="#media" class="left carousel-control">‹</a>
<a data-slide="next" href="#media" class="right carousel-control">›</a>
</div>
</div>
</div>
</div>
CSS
/* carousel */
.media-carousel
{
margin-bottom: 0;
padding: 0 40px 30px 40px;
margin-top: 30px;
}
/* Previous button */
.media-carousel .carousel-control.left
{
left: -12px;
background-image: none;
background: none repeat scroll 0 0 #222222;
border: 4px solid #FFFFFF;
border-radius: 23px 23px 23px 23px;
height: 40px;
width : 40px;
margin-top: 30px
}
/* Next button */
.media-carousel .carousel-control.right
{
right: -12px !important;
background-image: none;
background: none repeat scroll 0 0 #222222;
border: 4px solid #FFFFFF;
border-radius: 23px 23px 23px 23px;
height: 40px;
width : 40px;
margin-top: 30px
}
/* Changes the position of the indicators */
.media-carousel .carousel-indicators
{
right: 50%;
top: auto;
bottom: 0px;
margin-right: -19px;
}
/* Changes the colour of the indicators */
.media-carousel .carousel-indicators li
{
background: #c0c0c0;
}
.media-carousel .carousel-indicators .active
{
background: #333333;
}
.media-carousel img
{
width: 250px;
height: 100px
}
/* End carousel */
js
$(document).ready(function() {
$('#media').carousel({
pause: true,
interval: false,
});
});

Rows not aligned correctly in Bootstrap

I've been searching for hours for the solution but didn't find.
Here is my HTML and CSS. I don't understand why the image 'THE_IMAGE.png' is not correctly aligned with the div above it ?
Can someone help me ?
Thank you !
body p {
font-size: 1.2em;
}
body a:visited{
color: white;
}
.page-header {
text-align: center;
}
/* Actus */
#actus {
margin-bottom: 5em;
}
.section_title h1{
text-align: center;
}
.button_all_actus {
background-color: #38C8D6;
border-color: 1px solid white;
height: 90px;
display: table;
color: white;
table-layout: fixed;
border-style: solid;
border-width: 1px;
border-color: #FFFFFF;
}
.button_all_actus p {
display:table-cell;
vertical-align:middle;
font-weight: bold;
}
.button_actus_size_2 {
background-color: #38C8D6;
height: 50px;
display: table;
table-layout: fixed;
border-style: solid;
border-width: 1px;
border-color: #FFFFFF;
color: white;
}
.button_actus_size_2 p {
display:table-cell;
vertical-align:middle;
font-weight: bold;
}
.button_actus_size_3 {
background-color: #38C8D6;
height: 50px;
display: table;
border-style: solid;
border-width: 1px;
border-color: #FFFFFF;
color: white;
}
.button_actus_size_3 p {
display:table-cell;
vertical-align:middle;
font-weight: bold;
}
.text_loin {
margin-top: 180px;
}
.plus_loin {
margin-top: 3em;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<section id ="actus">
<div class="container">
<div class="row">
<div class="section_title">
<h1>LOREM</h1>
<hr class="divider_blue">
</div>
</div>
<div class="row all_actus">
<div class="col-md-4">
<h2>LOREM</h2>
</div>
<a href="#">
<div class="col-md-8 button_all_actus">
<p class="text-left">LOREM</p>
<p class="text-right"> → </p>
</div>
</a>
<a href="#">
<div class="col-md-4 col-md-offset-4 button_actus_size_2">
<p class="text-left">LOREM</p>
<p class="text-right"> → </p>
</div>
</a>
<a href="#">
<div class="col-md-4 col-md-offset button_actus_size_2">
<p class="text-left">LOREM</p>
<p class="text-right"> → </p>
</div>
</a>
<a href="#">
<div class="col-md-4 col-md-offset-4 button_actus_size_2">
<p class="text-left">LOREM</p>
<p class="text-right"> → </p>
</div>
</a>
<a href="#">
<div class="col-md-4 button_actus_size_2">
<p class="text-left">LOREM</p>
<p class="text-right"> → </p>
</div>
</a>
<a href="#">
<div class="col-md-8 col-md-offset-4 button_actus_size_3">
<p class="text-left">LOREM</p>
<p class="text-right"> → </p>
</div>
</a>
</div>
</div>
</section>
<section id="temoignages">
<div class="container">
<div class="row">
<div class="section_title">
<h1>Lorem</h1>
<hr class="divider_blue">
</div>
</div>
<div class="row">
<div class="col-md-7">
<p>Lorem ipsum</p>
</div>
<div class="col-md-3 col-md-offset-2">
<img src="<?php bloginfo('template_directory'); ?>/images/THE_IMAGE.png">
</div>
</div>
</div>
</section>
<?php get_footer(); ?>
as you can see, the image have padding-left: 15px and padding-right: 15px which is from bootstrap.css here:
.col-xs-1, .col-sm-1, .col-md-1, .col-lg-1, .col-xs-2, .col-sm-2, .col-md-2, .col-lg-2, .col-xs-3, .col-sm-3, .col-md-3, .col-lg-3, .col-xs-4, .col-sm-4, .col-md-4, .col-lg-4, .col-xs-5, .col-sm-5, .col-md-5, .col-lg-5, .col-xs-6, .col-sm-6, .col-md-6, .col-lg-6, .col-xs-7, .col-sm-7, .col-md-7, .col-lg-7, .col-xs-8, .col-sm-8, .col-md-8, .col-lg-8, .col-xs-9, .col-sm-9, .col-md-9, .col-lg-9, .col-xs-10, .col-sm-10, .col-md-10, .col-lg-10, .col-xs-11, .col-sm-11, .col-md-11, .col-lg-11, .col-xs-12, .col-sm-12, .col-md-12, .col-lg-12 {
position: relative;
min-height: 1px;
padding-left: 15px;
padding-right: 15px;
}
just using padding-right: 0; is not enough, you need to use padding-right: 0 !important; to force it.
easy way to test is to add background-color to the images parent.
Or you can add * { border: 1px solid red; } to your css to quickly check block size of all element.
body p {
font-size: 1.2em;
}
body a:visited{
color: white;
}
.divider_blue {
border-top: 5px solid #0BB0DE;
width: 30px;
border-radius: 40px;
}
.page-header {
text-align: center;
}
/* Actus */
#actus {
margin-bottom: 5em;
}
.section_title h1{
text-align: center;
}
.button_all_actus {
background-color: #38C8D6;
border-color: 1px solid white;
height: 90px;
display: table;
color: white;
table-layout: fixed;
border-style: solid;
border-width: 1px;
border-color: #FFFFFF;
}
.button_all_actus p {
display:table-cell;
vertical-align:middle;
font-weight: bold;
}
.button_actus_size_2 {
background-color: #38C8D6;
height: 50px;
display: table;
table-layout: fixed;
border-style: solid;
border-width: 1px;
border-color: #FFFFFF;
color: white;
}
.button_actus_size_2 p {
display:table-cell;
vertical-align:middle;
font-weight: bold;
}
.button_actus_size_3 {
background-color: #38C8D6;
height: 50px;
display: table;
border-style: solid;
border-width: 1px;
border-color: #FFFFFF;
color: white;
}
.button_actus_size_3 p {
display:table-cell;
vertical-align:middle;
font-weight: bold;
}
.text_loin {
margin-top: 180px;
}
.plus_loin {
margin-top: 3em;
}
.alignright {
text-align: right;
padding-right: 0 !important;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<section id ="actus">
<div class="container">
<div class="row">
<div class="section_title">
<h1>Actus</h1>
<hr class="divider_blue">
</div>
</div>
<div class="row all_actus">
<div class="col-md-4">
<h2>LOREM</h2>
</div>
<a href="#">
<div class="col-md-8 button_all_actus">
<p class="text-left">LOREM</p>
<p class="text-right"> → </p>
</div>
</a>
<a href="#">
<div class="col-md-4 col-md-offset-4 button_actus_size_2">
<p class="text-left">LOREM</p>
<p class="text-right"> → </p>
</div>
</a>
<a href="#">
<div class="col-md-4 col-md-offset button_actus_size_2">
<p class="text-left">LOREM</p>
<p class="text-right"> → </p>
</div>
</a>
<a href="#">
<div class="col-md-4 col-md-offset-4 button_actus_size_2">
<p class="text-left">LOREM</p>
<p class="text-right"> → </p>
</div>
</a>
<a href="#">
<div class="col-md-4 button_actus_size_2">
<p class="text-left">LOREM</p>
<p class="text-right"> → </p>
</div>
</a>
<a href="#">
<div class="col-md-8 col-md-offset-4 button_actus_size_3">
<p class="text-left">LOREM</p>
<p class="text-right"> → </p>
</div>
</a>
</div>
</div>
</section>
<section id="temoignages">
<div class="container">
<div class="row">
<div class="section_title">
<h1>Lorem</h1>
<hr class="divider_blue">
</div>
</div>
<div class="row">
<div class="col-md-7">
<p>Lorem ipsum</p>
</div>
<div class="col-md-3 col-md-offset-2 alignright">
<img src="https://dummyimage.com/242x242/000/fff">
</div>
</div>
</div>
</section>
put class="img-responsive" so it will fit the size of your parent div.
Explaination
img-responsive is a bootstrap classname that will automatically fit your image 100% width to your parent div. Example, if your parent div is 100px and the with of image is 500px, then your 500px image width will become same as 100px which is the width of the parent div (without resizing the document).
More explainations here:
https://v4-alpha.getbootstrap.com/content/images/
I tried it on my PC and it's working.. See code below.
<section id="temoignages">
<div class="container">
<div class="row">
<div class="section_title">
<h1>Lorem</h1>
<hr class="divider_blue">
</div>
</div>
<div class="row">
<div class="col-md-7">
<p>Lorem ipsum</p>
</div>
<div class="col-md-3 col-md-offset-2">
<img src="<?php bloginfo('template_directory'); ?>/images/THE_IMAGE.png" class="img-responsive">
</div>
</div>
</div>
</section>
body p {
font-size: 1.2em;
}
body a:visited{
color: white;
}
.divider_blue {
border-top: 5px solid #0BB0DE;
width: 30px;
border-radius: 40px;
}
.page-header {
text-align: center;
}
/* Actus */
#actus {
margin-bottom: 5em;
}
.section_title h1{
text-align: center;
}
.button_all_actus {
background-color: #38C8D6;
border-color: 1px solid white;
height: 90px;
display: table;
color: white;
table-layout: fixed;
border-style: solid;
border-width: 1px;
border-color: #FFFFFF;
}
.button_all_actus p {
display:table-cell;
vertical-align:middle;
font-weight: bold;
}
.button_actus_size_2 {
background-color: #38C8D6;
height: 50px;
display: table;
table-layout: fixed;
border-style: solid;
border-width: 1px;
border-color: #FFFFFF;
color: white;
}
.button_actus_size_2 p {
display:table-cell;
vertical-align:middle;
font-weight: bold;
}
.button_actus_size_3 {
background-color: #38C8D6;
height: 50px;
display: table;
border-style: solid;
border-width: 1px;
border-color: #FFFFFF;
color: white;
}
.button_actus_size_3 p {
display:table-cell;
vertical-align:middle;
font-weight: bold;
}
.text_loin {
margin-top: 180px;
}
.plus_loin {
margin-top: 3em;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<section id ="actus">
<div class="container">
<div class="row">
<div class="section_title">
<h1>Actus</h1>
<hr class="divider_blue">
</div>
</div>
<div class="row all_actus">
<div class="col-md-4">
<h2>LOREM</h2>
</div>
<a href="#">
<div class="col-md-8 button_all_actus">
<p class="text-left">LOREM</p>
<p class="text-right"> → </p>
</div>
</a>
<a href="#">
<div class="col-md-4 col-md-offset-4 button_actus_size_2">
<p class="text-left">LOREM</p>
<p class="text-right"> → </p>
</div>
</a>
<a href="#">
<div class="col-md-4 col-md-offset button_actus_size_2">
<p class="text-left">LOREM</p>
<p class="text-right"> → </p>
</div>
</a>
<a href="#">
<div class="col-md-4 col-md-offset-4 button_actus_size_2">
<p class="text-left">LOREM</p>
<p class="text-right"> → </p>
</div>
</a>
<a href="#">
<div class="col-md-4 button_actus_size_2">
<p class="text-left">LOREM</p>
<p class="text-right"> → </p>
</div>
</a>
<a href="#">
<div class="col-md-8 col-md-offset-4 button_actus_size_3">
<p class="text-left">LOREM</p>
<p class="text-right"> → </p>
</div>
</a>
</div>
</div>
</section>
<section id="temoignages">
<div class="container">
<div class="row">
<div class="section_title">
<h1>Lorem</h1>
<hr class="divider_blue">
</div>
</div>
<div class="row">
<div class="col-md-7">
<p>Lorem ipsum</p>
</div>
<div class="col-md-3 col-md-offset-2">
<img src="http://www.planwallpaper.com/static/images/desktop-year-of-the-tiger-images-wallpaper.jpg" class="img-responsive">
</div>
</div>
</div>
</section>

Resources