CSS sticky positioning forcing scroll to the top after page load - css

I'm experiencing an odd issue with the sticky positioning feature that's interfering with the scroll positioning.
My intention is fairly common: keep an advertisement in a sidebar always visible when the visitor scrolls the page.
It does work as per definition as you can see in the code below — or in the Fiddle if you prefer:
body {
margin: 6rem;
}
img {
width: 100%;
height: 100%;
object-fit: cover;
}
.sidebar .ads {
position: sticky;
top: 1rem;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container">
<div class="row">
<section class="col-md-10 listing">
<div class="row">
<div class="col-md-4">
<div class="card-deck">
<div class="card" data-mh="card">
<a href="">
<img class="card-img-top thumbnail" src="https://orig00.deviantart.net/63b7/f/2013/041/9/d/free_youtube_thumbnail_template_by_imaura-d5ugja7.png" alt="Thumbnail" />
</a>
<div class="card-block">
<h3 class="card-title d-flex align-items-center hidden-sm-down lang-en">
Title
</h3>
Et aliquip non culpa pariatur quis et consectetur dolor eu laborum in nisi voluptate ut commodo dolore dolore anim est et in eu voluptate velit nulla nisi occaecat anim ut.
</div>
</div>
</div>
</div>
<div class="col-md-4">
<div class="card-deck">
<div class="card" data-mh="card">
<a href="">
<img class="card-img-top thumbnail" src="https://orig00.deviantart.net/63b7/f/2013/041/9/d/free_youtube_thumbnail_template_by_imaura-d5ugja7.png" alt="Thumbnail" />
</a>
<div class="card-block">
<h3 class="card-title d-flex align-items-center hidden-sm-down lang-en">
Title
</h3>
Et aliquip non culpa pariatur quis et consectetur dolor eu laborum in nisi voluptate ut commodo dolore dolore anim est et in eu voluptate velit nulla nisi occaecat anim ut.
</div>
</div>
</div>
</div>
<div class="col-md-4">
<div class="card-deck">
<div class="card" data-mh="card">
<a href="">
<img class="card-img-top thumbnail" src="https://orig00.deviantart.net/63b7/f/2013/041/9/d/free_youtube_thumbnail_template_by_imaura-d5ugja7.png" alt="Thumbnail" />
</a>
<div class="card-block">
<h3 class="card-title d-flex align-items-center hidden-sm-down lang-en">
Title
</h3>
Et aliquip non culpa pariatur quis et consectetur dolor eu laborum in nisi voluptate ut commodo dolore dolore anim est et in eu voluptate velit nulla nisi occaecat anim ut.
</div>
</div>
</div>
</div>
<div class="col-md-4">
<div class="card-deck">
<div class="card" data-mh="card">
<a href="">
<img class="card-img-top thumbnail" src="https://orig00.deviantart.net/63b7/f/2013/041/9/d/free_youtube_thumbnail_template_by_imaura-d5ugja7.png" alt="Thumbnail" />
</a>
<div class="card-block">
<h3 class="card-title d-flex align-items-center hidden-sm-down lang-en">
Title
</h3>
Et aliquip non culpa pariatur quis et consectetur dolor eu laborum in nisi voluptate ut commodo dolore dolore anim est et in eu voluptate velit nulla nisi occaecat anim ut.
</div>
</div>
</div>
</div>
<div class="col-md-4">
<div class="card-deck">
<div class="card" data-mh="card">
<a href="">
<img class="card-img-top thumbnail" src="https://orig00.deviantart.net/63b7/f/2013/041/9/d/free_youtube_thumbnail_template_by_imaura-d5ugja7.png" alt="Thumbnail" />
</a>
<div class="card-block">
<h3 class="card-title d-flex align-items-center hidden-sm-down lang-en">
Title
</h3>
Et aliquip non culpa pariatur quis et consectetur dolor eu laborum in nisi voluptate ut commodo dolore dolore anim est et in eu voluptate velit nulla nisi occaecat anim ut.
</div>
</div>
</div>
</div>
<div class="col-md-4">
<div class="card-deck">
<div class="card" data-mh="card">
<a href="">
<img class="card-img-top thumbnail" src="https://orig00.deviantart.net/63b7/f/2013/041/9/d/free_youtube_thumbnail_template_by_imaura-d5ugja7.png" alt="Thumbnail" />
</a>
<div class="card-block">
<h3 class="card-title d-flex align-items-center hidden-sm-down lang-en">
Title
</h3>
Et aliquip non culpa pariatur quis et consectetur dolor eu laborum in nisi voluptate ut commodo dolore dolore anim est et in eu voluptate velit nulla nisi occaecat anim ut.
</div>
</div>
</div>
</div>
</div>
</section>
<section class="col-md-2 hidden-sm-down sidebar">
<div class="ads">
Sticky content
</div>
</section>
</div>
</div>
<div class="hidden-sm-up">
<br /><br /><br /><br />
</div>
However, if the real sticky content takes a while to load, which is very common with Google AdSense and alike, and the user starts scrolling down the page (or press Page Down, End, arrows...) when the said slow content finally finishes loading the whole page scrolls to the top.
I've debugged my JS to make sure it wasn't my fault. Also, when I removed the position: sticky; declaration jumping stopped.
More important than how could I fix this, I would like to know why this is happening

Related

bootstrap 4 alerts make text display across the alert box

I am using bootstrap 4 and I want the paragraph text to display across the width of the box. How can I make it spread over most of it?
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.1/css/all.min.css">
<div class="row">
<div class="col-md-2">
</div>
<div class="col-md-8">
<div class="alert alert-info">
<div class="row">
<p class="col-xs-12">
<div class="col-xs-2 col-md-2 col-sm-2 col-lg-2"> <i class="fas fa-hand-paper fa-3x" ></i>
</div>
<div class="col-xs-6 col-sm-6 col-md-6 col-lg-6">
<H2>
Message
</H2>
<h3>
title here
</h3>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</p>
</div>
</div>
</div>
Your message is displaying over the majority of the element's container. Your paragraph text, I assume to be the col-xs-6 class div element under the h3 (as this is the only paragraph element with text in it) is displaying 100% of its container.
If you want it to fit the entirety of the alert you need to make the container <div class="col-xs-6 col-sm-6 col-md-6 col-lg-6"> fit the entire row by changing the numbers 6 to 10:
<div class="col-xs-10 col-sm-10 col-md-10 col-lg-10">
This is because bootstrap runs off a 12 grid system. You had 4 unused grid spaces.
Read more here: https://getbootstrap.com/docs/4.0/layout/grid/
It should also be noted that col-xs is no longer supported in Bootstrap 4. The extra small size is now just col-number.

Making bootstrap Card display horizontal

I have made a bootstrap card in my website, and i want to make it horizontal.
and i want to convert it to .
Please provide solution by inspecting my code!
.blue-bg{
background-image: linear-gradient(#1385de,#045f9b);
color: white;
}
.brown-bg{
background-image: linear-gradient(#f8b949,#f7951f);
}
.order-btn2{
background-image: linear-gradient(#ffde5e,#fdd215);
color: black;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet"/>
<li class="card col-sm-3">
<img class="card-img-top" src="https://i.ibb.co/Tcn9qV7/phoneSms.png" alt="Card image">
<div class="card-header brown-bg">
SMS Order
</div>
<div class="card-body blue-bg p-0 mt-1">
<p class="card-text">Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit.</p>
Place Order
</div>
</li>
Thanks.
Basically bootstrap has inbuilt solution to it its Horizontal Card you can make card both in horizontal and vertical.
Here is a simple example for horizontal card.
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css" rel="stylesheet"/>
<div class="card mb-3" style="max-width: 540px;">
<div class="row no-gutters">
<div class="col-4">
<img src="https://via.placeholder.com/150" class="card-img" alt="...">
</div>
<div class="col-8">
<div class="card-body">
<h5 class="card-title">Card title</h5>
<p class="card-text">This is a wider card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
<p class="card-text"><small class="text-muted">Last updated 3 mins ago</small></p>
</div>
</div>
</div>
</div>

Bootstrap4: Extra whitespace on right side of the screen

My navbar at the top of the page is overflowing the viewport on smaller devices. I found this on my personal device and in the Chrome developer tools.
Starting at 575px there is a whitespace on the white side of the screen. As the viewport decreases, the whitespace inversely increases. At the smallest point the content takes up about 25% and the remaining 75% is white.
How can I make this extra whitespace go away? Thanks!
< script src = "https://code.jquery.com/jquery-3.4.1.slim.min.js"
integrity = "sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n"
crossorigin = "anonymous" > < /script>
<
script src = "https://cdn.jsdelivr.net/npm/popper.js#1.16.0/dist/umd/popper.min.js"
integrity = "sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo"
crossorigin = "anonymous" > < /script>
<
script src = "https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"
integrity = "sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6"
crossorigin = "anonymous" > < /script>
body {
position: relative;
}
h3 {
text-align: center;
}
nav {
position: inherit;
}
#home {
background-image: url(jumbotronNewResized.jpg);
text-align: center;
margin-top: 55px;
background-size: 100%;
background-repeat: no-repeat;
}
#lowerJumbotron {
color: white;
}
i {
padding-right: 8px;
}
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
<link href="fontawesome-free-5.11.2-web/css/all.min.css" rel="stylesheet">
<title>My App!</title>
</head>
<body data-spy="scroll" data-target="#topPageNavbar" data-offset="100">
<nav class="navbar navbar-expand-lg navbar-dark bg-secondary fixed-top" id="topPageNavbar">
<a class="navbar-brand font-weight-bold" href="#">My App Page</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#topNavbar" aria-controls="topNavbar" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="topNavbar">
<ul class="navbar-nav mr-auto">
<li class="nav-item active">
<a class="nav-link" href="#home">Home <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="#about">About</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#features">Features</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#download">Download</a>
</li>
</ul>
<form class="form-inline my-2 my-xs-0">
<input class="form-control mr-sm-2" type="email" placeholder="Email Address" aria-label="Email Address">
<input class="form-control mr-sm-2" type="password" placeholder="Password" aria-label="Password">
<button class="btn btn-outline-success bg-success my-2 my-sm-0 text-white font-weight-bold" type="submit">Login</button>
</form>
</div>
</nav>
<div class="jumbotron jumbotron-fluid" id="home">
<div class="container">
<h1 class="display-4">My Awesome App!</h1>
<p class="lead">This is why YOU should download this fantastic app!</p>
<hr class="my-2">
<p id="lowerJumbotron">Want to keep updated? Join our mailing list!</p>
<form>
<div class="form-row justify-content-center">
<div class="col-auto">
<div class="input-group">
<div class="input-group-prepend">
<div class="input-group-text">#</div>
</div>
<input type="email" class="form-control" placeholder="Your Email Address">
</div>
</div>
<div class="col-auto">
<button type="submit" class="btn btn-success">Submit</button>
</div>
</div>
</form>
</div>
</div>
<div id="about" class="container">
<h3 class="my-3">This is all about the app!</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure
dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<br>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure
dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
</div>
<hr class="container">
<div id="features" class="container mt-4">
<h3 class="mb-3">Check out some of the different features!</h3>
<div class="card-deck">
<div class="card">
<img src="seedsResized.jpg" class="card-img-top" alt="Seeds">
<div class="card-body">
<h5 class="card-title"><i class="fas fa-seedling icon"></i>Gather Your Seed</h5>
<p class="card-text">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
Click This Link!
</div>
</div>
<div class="card">
<img src="sprout.jpg" class="card-img-top" alt="Sprouting Seeds">
<div class="card-body">
<h5 class="card-title"><i class="fas fa-leaf icon"></i>Nuture Your Field</h5>
<p class="card-text">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
Click This Link!
</div>
</div>
<div class="card">
<img src="harvestResized.jpg" class="card-img-top" alt="...">
<div class="card-body">
<h5 class="card-title"><i class="fas fa-tractor icon"></i>Receive Your Harvest</h5>
<p class="card-text">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
Click This Link!
</div>
</div>
</div>
<div class="card-deck mt-4">
<div class="card">
<img src="calendar.jpg" class="card-img-top" alt="...">
<div class="card-body">
<h5 class="card-title"><i class="fas fa-tasks"></i>Plan Your Activity</h5>
<p class="card-text">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
Click This Link!
</div>
</div>
<div class="card">
<img src="meetingResized.jpg" class="card-img-top" alt="...">
<div class="card-body">
<h5 class="card-title"><i class="fas fa-handshake"></i>Schedule Your Success</h5>
<p class="card-text">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
Click This Link!
</div>
</div>
<div class="card">
<img src="dashboardResized.jpg" class="card-img-top" alt="...">
<div class="card-body">
<h5 class="card-title"><i class="fas fa-chart-line"></i>Monitor Your Growth</h5>
<p class="card-text">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
Click This Link!
</div>
</div>
</div>
</div>
<div id="download"></div>
<script src="https://code.jquery.com/jquery-3.4.1.slim.min.js" integrity="sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/popper.js#1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js" integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" crossorigin="anonymous"></script>
</body>
</html>
Link of the Website With Extra Whitespace On Small Screens
It has nothing to do with the navigation, the issue is with the horizontal ruler <hr> having a 100% width; add the following CSS to resolve:
hr.container {
width: auto;
}
complete working snippet:
body {
position: relative;
}
h3 {
text-align: center;
}
nav {
position: inherit;
}
#home {
background-image: url(jumbotronNewResized.jpg);
text-align: center;
margin-top: 55px;
background-size: 100%;
background-repeat: no-repeat;
}
#lowerJumbotron {
color: white;
}
i {
padding-right: 8px;
}
hr.container {
width: auto;
}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
<link href="fontawesome-free-5.11.2-web/css/all.min.css" rel="stylesheet">
<body data-spy="scroll" data-target="#topPageNavbar" data-offset="100">
<nav class="navbar navbar-expand-lg navbar-dark bg-secondary fixed-top" id="topPageNavbar">
<a class="navbar-brand font-weight-bold" href="#">My App Page</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#topNavbar" aria-controls="topNavbar" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="topNavbar">
<ul class="navbar-nav mr-auto">
<li class="nav-item active">
<a class="nav-link" href="#home">Home <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="#about">About</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#features">Features</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#download">Download</a>
</li>
</ul>
<form class="form-inline my-2 my-xs-0">
<input class="form-control mr-sm-2" type="email" placeholder="Email Address" aria-label="Email Address">
<input class="form-control mr-sm-2" type="password" placeholder="Password" aria-label="Password">
<button class="btn btn-outline-success bg-success my-2 my-sm-0 text-white font-weight-bold" type="submit">Login</button>
</form>
</div>
</nav>
<div class="jumbotron jumbotron-fluid" id="home">
<div class="container">
<h1 class="display-4">My Awesome App!</h1>
<p class="lead">This is why YOU should download this fantastic app!</p>
<hr class="my-2">
<p id="lowerJumbotron">Want to keep updated? Join our mailing list!</p>
<form>
<div class="form-row justify-content-center">
<div class="col-auto">
<div class="input-group">
<div class="input-group-prepend">
<div class="input-group-text">#</div>
</div>
<input type="email" class="form-control" placeholder="Your Email Address">
</div>
</div>
<div class="col-auto">
<button type="submit" class="btn btn-success">Submit</button>
</div>
</div>
</form>
</div>
</div>
<div id="about" class="container">
<h3 class="my-3">This is all about the app!</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure
dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<br>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure
dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
</div>
<hr class="container">
<div id="features" class="container mt-4">
<h3 class="mb-3">Check out some of the different features!</h3>
<div class="card-deck">
<div class="card">
<img src="seedsResized.jpg" class="card-img-top" alt="Seeds">
<div class="card-body">
<h5 class="card-title"><i class="fas fa-seedling icon"></i>Gather Your Seed</h5>
<p class="card-text">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
Click This Link!
</div>
</div>
<div class="card">
<img src="sprout.jpg" class="card-img-top" alt="Sprouting Seeds">
<div class="card-body">
<h5 class="card-title"><i class="fas fa-leaf icon"></i>Nuture Your Field</h5>
<p class="card-text">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
Click This Link!
</div>
</div>
<div class="card">
<img src="harvestResized.jpg" class="card-img-top" alt="...">
<div class="card-body">
<h5 class="card-title"><i class="fas fa-tractor icon"></i>Receive Your Harvest</h5>
<p class="card-text">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
Click This Link!
</div>
</div>
</div>
<div class="card-deck mt-4">
<div class="card">
<img src="calendar.jpg" class="card-img-top" alt="...">
<div class="card-body">
<h5 class="card-title"><i class="fas fa-tasks"></i>Plan Your Activity</h5>
<p class="card-text">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
Click This Link!
</div>
</div>
<div class="card">
<img src="meetingResized.jpg" class="card-img-top" alt="...">
<div class="card-body">
<h5 class="card-title"><i class="fas fa-handshake"></i>Schedule Your Success</h5>
<p class="card-text">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
Click This Link!
</div>
</div>
<div class="card">
<img src="dashboardResized.jpg" class="card-img-top" alt="...">
<div class="card-body">
<h5 class="card-title"><i class="fas fa-chart-line"></i>Monitor Your Growth</h5>
<p class="card-text">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
Click This Link!
</div>
</div>
</div>
</div>
<div id="download"></div>
<script src="https://code.jquery.com/jquery-3.4.1.slim.min.js" integrity="sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/popper.js#1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js" integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" crossorigin="anonymous"></script>
</body>

Prevent Bootstrap 4 auto-fill column from wrapping to next row

I have a component where a Bootstrap 4 auto-expand column is wrapping to another row. The presence of an element with the "text-truncate" class and long text is causing Chrome to vertically stack the column element under the row where it belongs.
In the snippet below, the <div> with ID, problem-div will wrap and consume the whole line if the child <span> element has Boostrap 4 class text-truncate applied and the element contains lengthy text. Remove the text-truncate class and the problem-div element will consume the unused portion of the first row in its container.
As it stands now, I can get the truncation feature for the child content - or I can get the parent column to fill the unused part of the first row of its parent, but not both. How do I get both at the same time?
img {
width: 16px;
height: 16px;
}
label {
margin: 0;
font-weight: 600;
}
.form-text {
margin: 0;
}
#problem-div {
background-color: #e0FFFF;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet" />
<body class="container-fluid">
...
<!-- lots of stuff -->
<div class="card">
<div class="card-header bg-warning">
<div class="row">
<div class="col-auto text-nowrap">
<img src=".../icon.png" />
<h6 class="pl-1 mt-1 font-weight-bold float-right">Label</h6>
</div>
<div class="col row small">
<div class="form-group col-3">
<label>ID</label>
<span class="form-text">1234567</span>
</div>
<div class="form-group col-3">
<label>Name</label>
<span class="form-text">My Name</span>
</div>
<div class="form-group col-3">
<label>Type</label>
<span class="form-text">Category-A</span>
</div>
<div class="form-group col-3">
<label>Code</label>
<span class="form-text">ABCDEFG</span>
</div>
</div>
</div>
</div>
<div class="card-body">
<div class="row">
<div class="col-auto text-nowrap invisible"> <img src=".../icon.png" />
<h6 class="pl-1 mt-1 font-weight-bold float-right">Label</h6>
</div>
<div class="col small">
<!-- Problem Div, breaks the auto-fill feature of its parent when "text-truncate" class is applied. -->
<div id="problem-div" class="text-truncate">
<label>Display Field Label</label>
<span class="form-text">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</span>
</div>
</div>
</div>
</div>
</div>
...
<!-- more stuff -->
</body>
When a flex item contains child elements with text that should be truncated, layout can be broken.
My first solution is add min-width: 0 to problem-div's parent (take a look at css trick article: https://css-tricks.com/flexbox-truncated-text/):
img {
width: 16px;
height: 16px;
}
label {
margin: 0;
font-weight: 600;
}
.form-text {
margin: 0;
}
#problem-div {
background-color: #e0FFFF;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet" />
<body class="container-fluid">
...
<!-- lots of stuff -->
<div class="card">
<div class="card-header bg-warning">
<div class="row">
<div class="col-auto text-nowrap">
<img src=".../icon.png" />
<h6 class="pl-1 mt-1 font-weight-bold float-right">Label</h6>
</div>
<div class="col row small">
<div class="form-group col-3">
<label>ID</label>
<span class="form-text">1234567</span>
</div>
<div class="form-group col-3">
<label>Name</label>
<span class="form-text">My Name</span>
</div>
<div class="form-group col-3">
<label>Type</label>
<span class="form-text">Category-A</span>
</div>
<div class="form-group col-3">
<label>Code</label>
<span class="form-text">ABCDEFG</span>
</div>
</div>
</div>
</div>
<div class="card-body">
<div class="row">
<div class="col-auto text-nowrap invisible"> <img src=".../icon.png" />
<h6 class="pl-1 mt-1 font-weight-bold float-right">Label</h6>
</div>
<div class="col small" style="min-width: 0">
<!-- Problem Div, breaks the auto-fill feature of its parent when "text-truncate" class is applied. -->
<div id="problem-div" class="text-truncate">
<label>Display Field Label</label>
<span class="form-text">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</span>
</div>
</div>
</div>
</div>
</div>
...
<!-- more stuff -->
</body>
Another solution is add overflow: hidden to problem-div's parent:
img {
width: 16px;
height: 16px;
}
label {
margin: 0;
font-weight: 600;
}
.form-text {
margin: 0;
}
#problem-div {
background-color: #e0FFFF;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet" />
<body class="container-fluid">
...
<!-- lots of stuff -->
<div class="card">
<div class="card-header bg-warning">
<div class="row">
<div class="col-auto text-nowrap">
<img src=".../icon.png" />
<h6 class="pl-1 mt-1 font-weight-bold float-right">Label</h6>
</div>
<div class="col row small">
<div class="form-group col-3">
<label>ID</label>
<span class="form-text">1234567</span>
</div>
<div class="form-group col-3">
<label>Name</label>
<span class="form-text">My Name</span>
</div>
<div class="form-group col-3">
<label>Type</label>
<span class="form-text">Category-A</span>
</div>
<div class="form-group col-3">
<label>Code</label>
<span class="form-text">ABCDEFG</span>
</div>
</div>
</div>
</div>
<div class="card-body">
<div class="row">
<div class="col-auto text-nowrap invisible"> <img src=".../icon.png" />
<h6 class="pl-1 mt-1 font-weight-bold float-right">Label</h6>
</div>
<!-- New CSS style -->
<div class="col small" style="overflow: hidden;">
<!-- Problem Div, breaks the auto-fill feature of its parent when "text-truncate" class is applied. -->
<div id="problem-div" class="text-truncate">
<label>Display Field Label</label>
<span class="form-text">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</span>
</div>
</div>
</div>
</div>
</div>
...
<!-- more stuff -->
</body>
Hope this help.

Bootstrap 3: images not resizing correctly in columns

I'm trying to achieve the layout below, but my HTML isn't working correctly. Can someone tell me why it's not working?
<div id="technologies-skills">
<div class="container">
<div class="row">
<h3 class="header">TECHNOLOGIES & SKILLS</h3>
<div class="col-md-2"></div>
<div class="col-md-4">
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Nam liber tempor cum soluta nobis eleifend option congue nihil imperdiet doming id quod mazim placerat facer possim assum. Typi non habent claritatem insitam; est usus legentis in iis qui facit eorum claritatem. Investigationes demonstraverunt lectores legere me lius quod ii legunt saepius. Claritas est etiam processus dynamicus, qui sequitur mutationem consuetudium lectorum. Mirum est notare quam littera gothica, quam nunc putamus parum claram, anteposuerit litterarum formas humanitatis per seacula quarta decima et quinta decima. Eodem modo typi, qui nunc nobis videntur parum clari, fiant sollemnes in futurum.</p>
</div>
<div class="row">
<div class="col-md-6">
<div class"col-md-1">
<img src="images/logos/android_logo.png" class="img-rounded img-responsive center-block" alt="Android Logo" />
</div>
<div class"col-md-1">
<img src="images/logos/android_logo.png" class="img-rounded img-responsive center-block" alt="Android Logo" />
</div>
<div class"col-md-1">
<img src="images/logos/android_logo.png" class="img-rounded img-responsive center-block" alt="Android Logo" />
</div>
<div class"col-md-1">
<img src="images/logos/android_logo.png" class="img-rounded img-responsive center-block" alt="Android Logo" />
</div>
<div class"col-md-1">
<img src="images/logos/android_logo.png" class="img-rounded img-responsive center-block" alt="Android Logo" />
</div>
<div class"col-md-1">
<img src="images/logos/android_logo.png" class="img-rounded img-responsive center-block" alt="Android Logo" />
</div>
</div>
</div>
</div>
</div> <!-- container -->
</div> <!-- technologie-skills -->
You are also missing "=" on classes
<div class"col-md-1">
should be: <div class="col-md-1">
You're just missing some divs. Whenever you need to subdivide, do it in a row. When you're inside a row, everything (by default) is divided by 12 (in Bootstrap 3).
http://jsfiddle.net/emptywalls/8JvNT/
<div class="container">
<div class="row">
<div class="col-xs-6">left column</div>
<div class="col-xs-6">
<div class="row">
<div class="col-xs-2">a</div>
<div class="col-xs-2">b</div>
<div class="col-xs-2">c</div>
<div class="col-xs-2">d</div>
<div class="col-xs-2">e</div>
<div class="col-xs-2">f</div>
</div>
<div class="row">
<div class="col-xs-2">g</div>
<div class="col-xs-2">h</div>
<div class="col-xs-2">i</div>
<div class="col-xs-2">j</div>
<div class="col-xs-2">k</div>
<div class="col-xs-2">l</div>
</div>
</div>
</div>
</div>

Resources