Weird movement on bootstrap carousel - css

So I built this "testimonial" slider on my website using bootstrap's carousel plugin but for some reason the movement seems clunky when it changes slides.. I'm not sure if it's my doing on the CSS because I styled on top of some of the elements and I don't really know too much of CSS..
Anyway, here's my code:
HTML
<div class="container-fluid">
<div class="row testimonials">
<div class="container">
<div class="row">
<div class="col-md-12">
<h3 class="text-center">Testimonials</h3>
</div>
</div>
<div class="carousel slide" id="testimonial_slider" data-ride="carousel">
<ol class="carousel-indicators">
<li data-target="#testimonial_slider" data-slide-to="0" class="active"></li>
<li data-target="#testimonial_slider" data-slide-to="1"></li>
<li data-target="#testimonial_slider" data-slide-to="2"></li>
</ol>
<div class="carousel-inner" role="listbox">
<div class="row item active">
<div class="col-md-6 testimonial">
<img src="my-image-url.jpg">
<p><i class="fa fa-quote-left"></i> The content</p>
<span>The Title</span>
</div>
<div class="col-md-6 testimonial">
<img src="my-image-url.jpg">
<p><i class="fa fa-quote-left"></i> The content</p>
<span>The Title</span>
</div>
</div>
<div class="row item active">
<div class="col-md-6 testimonial">
<img src="my-image-url.jpg">
<p><i class="fa fa-quote-left"></i> The content</p>
<span>The Title</span>
</div>
<div class="col-md-6 testimonial">
<img src="my-image-url.jpg">
<p><i class="fa fa-quote-left"></i> The content</p>
<span>The Title</span>
</div>
</div>
<div class="row item active">
<div class="col-md-6 testimonial">
<img src="my-image-url.jpg">
<p><i class="fa fa-quote-left"></i> The content</p>
<span>The Title</span>
</div>
<div class="col-md-6 testimonial">
<img src="my-image-url.jpg">
<p><i class="fa fa-quote-left"></i> The content</p>
<span>The Title</span>
</div>
</div>
</div>
</div>
</div>
</div>
And the CSS:
.testimonials {
padding-bottom:30px;
}
.testimonial {
position:relative;
height:100px;
margin:10px 0 20px 0;
padding:0 20px 20px 120px;
box-sizing:border-box;
}
.testimonial p i {
color:#eb7022;
}
.testimonial span {
position:absolute;
bottom:0;
left:130px;
}
.testimonial img {
height:100px;
width:100px;
margin-right:120px;
border-radius:6px;
position:absolute;
top:0;
left:16px;
}
You can also see it live here.
Am I breaking something with these styles?
Any help appreciated, thanks!

Don't use .row with .item.
Apply .active class only to first item.
Instead of this:
<div class="row item active">
<div class="col-md-6 testimonial">
<img src="1.jpg">
<p><i class="fa fa-quote-left"></i> The content</p>
<span>The Title</span>
</div>
<div class="col-md-6 testimonial">
<img src="1.jpg">
<p><i class="fa fa-quote-left"></i> The content</p>
<span>The Title</span>
</div>
</div>
Use this:
<div class="item active">
<div class="row>
<div class="col-md-6 testimonial">
<img src="1.jpg">
<p><i class="fa fa-quote-left"></i> The content</p>
<span>The Title</span>
</div>
<div class="col-md-6 testimonial">
<img src="1.jpg">
<p><i class="fa fa-quote-left"></i> The content</p>
<span>The Title</span>
</div>
</div>
</div>

Related

Card Column Count not exceeding 6 columns

I want to have multiple cards next to each other (preferebly 10), but the webpage only shows 6 at most.
Here is the css:
#media (min-width: 576px) {
/* line 256, node_modules/bootstrap/scss/_card.scss */
.card-columns2 {
-webkit-column-count: 7;
column-count: 7;
-moz-column-count: 7;
-webkit-column-gap: 1.25rem;
column-gap: 1.25rem;
-moz-column-count: 1.25rem;
width: 100%;
orphans: 1;
widows: 1;}
/* line 267, node_modules/bootstrap/scss/_card.scss */
.card-columns2 .card {
display: inline-block;
width: 100%;
} }
And here is the snippet of the HTML code:
<div class="mb-4 container-fluid" >
<div class="row" >
<div class="card-columns2">
<div class="card card-pin">
<img class="card-img" src="https://snipp" alt="#1481">
<div class="text-block" >
</div>
<div class="overlay">
<h2 class="card-title title"></h2>
<div class="more">
<a href="post.html">
<i class="fa fa-arrow-circle-o-right" aria-hidden="true"></i> More </a>
</div>
</div>
</div>
<div class="card card-pin">
<img class="card-img" src="snipp" alt="#1546">
<div class="text-block" >
</div>
<div class="overlay">
<h2 class="card-title title"></h2>
<div class="more">
<a href="post.html">
<i class="fa fa-arrow-circle-o-right" aria-hidden="true"></i> More </a>
</div>
</div>
</div>
And that's how it looks like with column count of 7:
enter image description here
It looks the same for the count of 10, but with smaller boxes.
#media (min-width: 576px) {
/* line 256, node_modules/bootstrap/scss/_card.scss */
.card-columns2 {
-webkit-column-count: 10;
column-count: 10;
-moz-column-count: 10;
-webkit-column-gap: 1.25rem;
column-gap: 1.25rem;
-moz-column-count: 1.25rem;
width: 100%;
orphans: 1;
widows: 1;}
/* line 267, node_modules/bootstrap/scss/_card.scss */
.card-columns2 .card {
display: inline-block;
width: 100%;
padding: 0 15px;
} }
<div class="mb-4 container-fluid">
<div class="row">
<div class="card-columns2">
<div class="card card-pin">
<img class="card-img" src="https://via.placeholder.com/200x200.jpg?text=irtiza" alt="#1481">
<div class="text-block">
</div>
<div class="overlay">
<h2 class="card-title title"></h2>
<div class="more">
<a href="post.html">
<i class="fa fa-arrow-circle-o-right" aria-hidden="true"></i> More </a>
</div>
</div>
</div>
<div class="card card-pin">
<img class="card-img" src="https://via.placeholder.com/200x200.jpg?text=irtiza" alt="#1546">
<div class="text-block">
</div>
<div class="overlay">
<h2 class="card-title title"></h2>
<div class="more">
<a href="post.html">
<i class="fa fa-arrow-circle-o-right" aria-hidden="true"></i> More </a>
</div>
</div>
</div
</div>
<div class="card card-pin">
<img class="card-img" src="https://via.placeholder.com/200x200.jpg?text=irtiza" alt="#1546">
<div class="text-block">
</div>
<div class="overlay">
<h2 class="card-title title"></h2>
<div class="more">
<a href="post.html">
<i class="fa fa-arrow-circle-o-right" aria-hidden="true"></i> More </a>
</div>
</div>
</div>
<div class="card card-pin">
<img class="card-img" src="https://via.placeholder.com/200x200.jpg?text=irtiza" alt="#1481">
<div class="text-block">
</div>
<div class="overlay">
<h2 class="card-title title"></h2>
<div class="more">
<a href="post.html">
<i class="fa fa-arrow-circle-o-right" aria-hidden="true"></i> More </a>
</div>
</div>
</div>
<div class="card card-pin">
<img class="card-img" src="https://via.placeholder.com/200x200.jpg?text=irtiza" alt="#1546">
<div class="text-block">
</div>
<div class="overlay">
<h2 class="card-title title"></h2>
<div class="more">
<a href="post.html">
<i class="fa fa-arrow-circle-o-right" aria-hidden="true"></i> More </a>
</div>
</div>
</div>
<div class="card card-pin">
<img class="card-img" src="https://via.placeholder.com/200x200.jpg?text=irtiza" alt="#1481">
<div class="text-block">
</div>
<div class="overlay">
<h2 class="card-title title"></h2>
<div class="more">
<a href="post.html">
<i class="fa fa-arrow-circle-o-right" aria-hidden="true"></i> More </a>
</div>
</div>
</div>
<div class="card card-pin">
<img class="card-img" src="https://via.placeholder.com/200x200.jpg?text=irtiza" alt="#1546">
<div class="text-block">
</div>
<div class="overlay">
<h2 class="card-title title"></h2>
<div class="more">
<a href="post.html">
<i class="fa fa-arrow-circle-o-right" aria-hidden="true"></i> More </a>
</div>
</div>
</div>
<div class="card card-pin">
<img class="card-img" src="https://via.placeholder.com/200x200.jpg?text=irtiza" alt="#1481">
<div class="text-block">
</div>
<div class="overlay">
<h2 class="card-title title"></h2>
<div class="more">
<a href="post.html">
<i class="fa fa-arrow-circle-o-right" aria-hidden="true"></i> More </a>
</div>
</div>
</div>
<div class="card card-pin">
<img class="card-img" src="https://via.placeholder.com/200x200.jpg?text=irtiza" alt="#1546">
<div class="text-block">
</div>
<div class="overlay">
<h2 class="card-title title"></h2>
<div class="more">
<a href="post.html">
<i class="fa fa-arrow-circle-o-right" aria-hidden="true"></i> More </a>
</div>
</div>
</div>
<div class="card card-pin">
<img class="card-img" src="https://via.placeholder.com/200x200.jpg?text=irtiza" alt="#1546">
<div class="text-block">
</div>
<div class="overlay">
<h2 class="card-title title"></h2>
<div class="more">
<a href="post.html">
<i class="fa fa-arrow-circle-o-right" aria-hidden="true"></i> More </a>
</div>
</div>
</div>
</div>
</div>
</div>
The only change you need to update your css, -webkit-column-count: 10; in all where you use column count.
thanks

Having a hard time targeting <img> using :nth-child()

I'm having a hard time targetting the second <img> tag to apply a .css rule to it but it's not working:
This is my code:
.product-highlights img:nth-of-type(2) {
margin: 0 4px;
}
<div class="product-highlights">
<div class="grid-container full">
<div class="grid-x">
<div class="cell small-4">
<a href="#">
<img src="http://via.placeholder.com/350x150" alt="Discounts">
</a>
</div>
<div class="cell small-4">
<a href="#">
<img src="http://via.placeholder.com/350x150" alt="Discounts">
</a>
</div>
<div class="cell small-4">
<a href="#">
<img src="http://via.placeholder.com/350x150" alt="Discounts">
</a>
</div>
</div>
</div>
</div>
What am I doing wrong?
As I noted in my comment above, nth-of-type only looks at siblings, so in your case target the image's parent divs instead:
.product-highlights .cell:nth-of-type(2) img{
margin: 0 4px;
}
<div class="product-highlights">
<div class="grid-container full">
<div class="grid-x">
<div class="cell small-4">
<a href="#">
<img src="http://via.placeholder.com/350x150" alt="Discounts">
</a>
</div>
<div class="cell small-4">
<a href="#">
<img src="http://via.placeholder.com/350x150" alt="Discounts">
</a>
</div>
<div class="cell small-4">
<a href="#">
<img src="http://via.placeholder.com/350x150" alt="Discounts">
</a>
</div>
</div>
</div>
</div>
pick secound div that holding image and then apply css to that image
.product-highlights .cell:nth-child(2) img{
margin: 0 4px;
}
<div class="product-highlights">
<div class="grid-container full">
<div class="grid-x">
<div class="cell small-4">
<a href="#">
<img src="http://via.placeholder.com/350x150" alt="Discounts">
</a>
</div>
<div class="cell small-4">
<a href="#">
<img src="http://via.placeholder.com/350x150" alt="Discounts">
</a>
</div>
<div class="cell small-4">
<a href="#">
<img src="http://via.placeholder.com/350x150" alt="Discounts">
</a>
</div>
</div>
</div>
</div>

Bootstrap 4 full width carousel showing other slides

I'm using Bootstrap 4 carousel and trying to make it full width. And at first glance, it looks like full width, but then when you take a look at it at larger screens, the rest of the sliders after the first one show up as well. Just try zooming out the window.
How can I fix this?
Here's my code:
.first-slide {
background: url("https://image.ibb.co/kvhXGH/jetty_1373173_1920.jpg");
}
.carousel-item {
height: 800px;
width: 100%;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-beta.2/css/bootstrap.css" rel="stylesheet" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>
<div class="container-fluid p-0">
<div id="carouselExampleControls" class="carousel slide" data-ride="carousel" data-interval="false">
<div class="carousel-inner" role="listbox">
<div class="carousel-item active first-slide">
<div class="row">
<div class="col-md-6 offset-md-1">
<h1>Title</h1>
<p>Text goes here</p>
</div>
<div class="col-md-5"></div>
</div>
</div>
<div class="carousel-item first-slide">
<div class="row">
<div class="col-md-6 offset-md-1">
<h1>Title</h1>
<p>Text goes here</p>
</div>
<div class="col-md-5"></div>
</div>
</div>
<div class="carousel-item first-slide">
<div class="row">
<div class="col-md-6 offset-md-1">
<h1>Title</h1>
<p>Text goeshere</p>
</div>
<div class="col-md-5"></div>
</div>
</div>
</div>
<a class="carousel-control-prev" href="#carouselExampleControls" role="button" data-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
</div>
</div>
Have you considered checking the markup on Bootstrap's website?
.carousel-item img {
max-height: 100vh;
object-fit: cover;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-beta.2/css/bootstrap.css" rel="stylesheet" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>
<div id="carouselExampleControls" class="carousel slide" data-ride="carousel">
<div class="carousel-inner">
<div class="carousel-item active">
<img class="d-block w-100" src="https://image.ibb.co/kvhXGH/jetty_1373173_1920.jpg" alt="First slide">
<div class="carousel-caption d-none d-md-block">
<h5>Title</h5>
<p>Text goes here</p>
</div>
</div>
<div class="carousel-item">
<img class="d-block w-100" src="https://image.ibb.co/kvhXGH/jetty_1373173_1920.jpg" alt="Second slide">
<div class="carousel-caption d-none d-md-block">
<h5>Title</h5>
<p>Text goes here</p>
</div>
</div>
<div class="carousel-item">
<img class="d-block w-100" src="https://image.ibb.co/kvhXGH/jetty_1373173_1920.jpg" alt="Third slide">
<div class="carousel-caption d-none d-md-block">
<h5>Title</h5>
<p>Text goes here</p>
</div>
</div>
</div>
<a class="carousel-control-prev" href="#carouselExampleControls" 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="#carouselExampleControls" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>

Bootstrap col-sm-6 3 items per line

I have a container with a row and inside that six portfolios items.
This code when used on a small screen I get the following result:
1st line : 2 images
2nd line : 1 image on the right side
3rd line : 2 images
4th line : 1 image on the left side
Anyone got a clue? Seems like a bug to me.
<div class="container">
<div class="row">
<div class="col-md-4 col-sm-6 col-xs-12">
<div class="portfolio-thumb">
<img src="images/portfolio-img1.png" alt="image" class="img-responsive">
<div class="portfolio-overlay">
<h2>Project One</h2>
<a href="#">
<i class="fa fa-search"></i>
</a>
</div>
</div>
</div>
<div class="col-md-4 col-sm-6 col-xs-12">
<div class="portfolio-thumb">
<img src="images/portfolio-img2.png" alt="image" class="img-responsive">
<div class="portfolio-overlay">
<h2>Project One</h2>
<a href="#">
<i class="fa fa-search"></i>
</a>
</div>
</div>
</div>
<div class="col-md-4 col-sm-6 col-xs-12">
<div class="portfolio-thumb">
<img src="images/portfolio-img3.png" alt="image" class="img-responsive">
<div class="portfolio-overlay">
<h2>Project One</h2>
<a href="#">
<i class="fa fa-search"></i>
</a>
</div>
</div>
</div>
<div class="col-md-4 col-sm-6 col-xs-12">
<div class="portfolio-thumb">
<img src="images/portfolio-img4.png" alt="image" class="img-responsive">
<div class="portfolio-overlay">
<h2>Project One</h2>
<a href="#">
<i class="fa fa-search"></i>
</a>
</div>
</div>
</div>
<div class="col-md-4 col-sm-6 col-xs-12">
<div class="portfolio-thumb">
<img src="images/portfolio-img1.png" alt="image" class="img-responsive">
<div class="portfolio-overlay">
<h2>Project One</h2>
<a href="#">
<i class="fa fa-search"></i>
</a>
</div>
</div>
</div>
<div class="col-md-4 col-sm-6 col-xs-12">
<div class="portfolio-thumb">
<img src="images/portfolio-img1.png" alt="image" class="img-responsive">
<div class="portfolio-overlay">
<h2>Project One</h2>
<a href="#">
<i class="fa fa-search"></i>
</a>
</div>
</div>
</div>
</div>
</div>
This is due to the different height of each post image, to avoid this use same size images or set the height of your <div class="col-md-4 col-sm-6 col-xs-12">...</div> similar to each other.
You can use the background-image property instead of just using <img> on the <div>.
Solution:
.portfolio-thumb {
width: 300px;
height: 200px;
background-size: cover;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container">
<div class="row">
<div class="col-md-4 col-sm-6 col-xs-12">
<div class="portfolio-thumb" style="background-image: url('http://placehold.it/300x200');"></div>
<div class="portfolio-overlay">
<h2>Project One</h2>
<a href="#">
<i class="fa fa-search"></i>
</a>
</div>
</div>
<div class="col-md-4 col-sm-6 col-xs-12">
<div class="portfolio-thumb" style="background-image: url('http://placehold.it/300x200');"></div>
<div class="portfolio-overlay">
<h2>Project One</h2>
<a href="#">
<i class="fa fa-search"></i>
</a>
</div>
</div>
<div class="col-md-4 col-sm-6 col-xs-12">
<div class="portfolio-thumb" style="background-image: url('http://placehold.it/300x200');"></div>
<div class="portfolio-overlay">
<h2>Project One</h2>
<a href="#">
<i class="fa fa-search"></i>
</a>
</div>
</div>
<div class="col-md-4 col-sm-6 col-xs-12">
<div class="portfolio-thumb" style="background-image: url('http://placehold.it/300x200');"></div>
<div class="portfolio-overlay">
<h2>Project One</h2>
<a href="#">
<i class="fa fa-search"></i>
</a>
</div>
</div>
<div class="col-md-4 col-sm-6 col-xs-12">
<div class="portfolio-thumb" style="background-image: url('http://placehold.it/300x200');"></div>
<div class="portfolio-overlay">
<h2>Project One</h2>
<a href="#">
<i class="fa fa-search"></i>
</a>
</div>
</div>
<div class="col-md-4 col-sm-6 col-xs-12">
<div class="portfolio-thumb" style="background-image: url('http://placehold.it/300x200');"></div>
<div class="portfolio-overlay">
<h2>Project One</h2>
<a href="#">
<i class="fa fa-search"></i>
</a>
</div>
</div>
</div>
</div>
Hope this helps!

Is it possible to push up a div in a row to fill empty space of the above row?

I have a layout problem, summarized in the images.
Practically, I have two rows containing span4 divs. The problem is that one div of the first row is too high and it dictates the height of the row. In the second row, I have a small div, which would be great if it could fill the empty space of the row above. Is there a css3 trick to do that?
Please, take a look at the images. I've added a jsfiddle here:
http://jsfiddle.net/XmZwh/3/
<body>
<div class="container">
<div class="row-fluid">
<div class="span12">
<div class="row-fluid">
<div class="span4">
<div class="sub1"> <span class="icon-play"></span>item 1
</div>
<div class="row-fluid">
<div class="span11 offset1">
<div class="sub2"> <a href="">item
</a>
</div>
</div>
</div>
<div class="row-fluid">
<div class="span11 offset1">
<div class="sub2"> <a href="">item
</a>
</div>
</div>
</div>
</div>
<div class="span4">
<div class="sub1"> <span class="icon-play"></span>items
</div>
<div class="row-fluid">
<div class="span11 offset1">
<div class="sub2"> <a href="">item
</a>
</div>
</div>
</div>
<div class="row-fluid">
<div class="span11 offset1">
<div class="sub2"> <a href="">item
</a>
</div>
</div>
</div>
<div class="row-fluid">
<div class="span11 offset1">
<div class="sub2"> <a href="">item
</a>
</div>
</div>
</div>
</div>
<div class="span4">
<div class="sub1"> <span class="icon-play"></span>item
</div>
<div class="row-fluid">
<div class="span11 offset1">
<div class="sub2"> <a href="">item
</a>
</div>
</div>
</div>
<div class="row-fluid">
<div class="span11 offset1">
<div class="sub2"> <a href="">item
</a>
</div>
</div>
</div>
<div class="row-fluid">
<div class="span11 offset1">
<div class="sub2"> <a href="">item
</a>
</div>
</div>
</div>
<div class="row-fluid">
<div class="span11 offset1">
<div class="sub2"> <a href="">item
</a>
</div>
</div>
</div>
<div class="row-fluid">
<div class="span11 offset1">
<div class="sub2"> <a href="">item
</a>
</div>
</div>
</div>
<div class="row-fluid">
<div class="span11 offset1">
<div class="sub2"> <a href="">item
</a>
</div>
</div>
</div>
</div>
</div>
<div class="row-fluid">
<div class="span4">
<div class="sub1"> <span class="icon-play"></span>item
</div>
<div class="row-fluid">
<div class="span11 offset1">
<div class="sub2"> <a href="">item
</a>
</div>
</div>
</div>
<div class="row-fluid">
<div class="span11 offset1">
<div class="sub2"> <a href="">item
</a>
</div>
</div>
</div>
<div class="row-fluid">
<div class="span11 offset1">
<div class="sub2"> <a href="">item
</a>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
The html comes out of a dynamic construction of a menu, based on items stored in a CMS, so I don't have so much control over that.
the only way to do this is by having a containing div that contains a and d,
Here is a jsfiddle link: http://jsfiddle.net/jQYtd/
<div class"cont">
<div class="cont2">
<div id="a">A</div>
<div id="d">D</div>
</div>
<div id="b">B</div>
<div id="c">C</div>
and the css
.cont {
overflow:auto;
border:1px solid #ccc;
}
.cont2, #a, #b, #c {
float:left;
background-color:grey;
width:30px;
}
#a, #b, #c{
background-color:green;
height:30px;
}
#c {
background-color:red;
height:60px;
}
if you have no control over the HTML you can use jquery to add cont2 div
to do that via jquery you would do something like this
$( "#a, #d" ).wrapAll( "<div class='cont2'></div>" );

Resources