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!
Related
I am new to Bootstrap. I am trying to add images as cards. But I face some issues as the cards are stacking up one after the other without spaces. Below is the code with Bootstrap4.
<body>
<div class="container-fluid">
<div class="row">
<div class="col-lg-3 col-md-4 col-sm-6 col-xs-12 card">
<a href="#" class="">
Beautiful
<img class="img-fluid " src="https://upload.wikimedia.org/wikipedia/en/2/25/Bazzi_-_Beautiful.jpeg" alt="" srcset="">
</a>
</div>
<div class="col-lg-3 col-md-4 col-sm-6 col-xs-12 card ">
<a href="#">
Beautiful
<img class="img-fluid" src="https://upload.wikimedia.org/wikipedia/en/e/e4/Beautiful_Bazzi_Camila_Cabello_Single.png" alt="" srcset="">
</a>
</div>
<div class="col-lg-3 col-md-4 col-sm-6 col-xs-12 card ">
<a href="#" class="">
Beautiful
<img class="img-fluid" src="https://upload.wikimedia.org/wikipedia/en/2/25/Bazzi_-_Beautiful.jpeg" alt="" srcset="">
</a>
</div>
<div class="col-lg-3 col-md-4 col-sm-6 col-xs-12 card">
<a href="#">
Beautiful
<img class="img-fluid" src="https://upload.wikimedia.org/wikipedia/en/e/e4/Beautiful_Bazzi_Camila_Cabello_Single.png" alt="" srcset="">
</a>
</div>
<div class="col-lg-3 col-md-4 col-sm-6 col-xs-12 card ">
<a href="#" class="">
Beautiful
<img class="img-fluid " src="https://upload.wikimedia.org/wikipedia/en/2/25/Bazzi_-_Beautiful.jpeg" alt="" srcset="">
</a>
</div>
<div class="col-lg-3 col-md-4 col-sm-6 col-xs-12 card ">
<a href="#">
Beautiful
<img class="img-fluid" src="https://upload.wikimedia.org/wikipedia/en/e/e4/Beautiful_Bazzi_Camila_Cabello_Single.png" alt="" srcset="">
</a>
</div>
</div>
</div>
With the above code in screen cards are stacked one after other without space.
I tried with mr-1 but the 4th card is wrapping it into another row.
How can I add spaces between cards with evenly spaced above and below?
This is because you are using .col-* and .card on the same element. Try to be in the habit of putting your content elements inside your layout grid elements.
<div class="container-fluid">
<div class="row">
<div class="col-lg-3 col-md-4 col-sm-6 col-xs-12">
<div class="card m-1">
<a href="#" class="">
Beautiful
<img class="img-fluid " src="https://upload.wikimedia.org/wikipedia/en/2/25/Bazzi_-_Beautiful.jpeg" alt="" srcset="">
</a>
</div>
</div>
<div class="col-lg-3 col-md-4 col-sm-6 col-xs-12">
<div class="card m-1">
<a href="#">
Beautiful
<img class="img-fluid" src="https://upload.wikimedia.org/wikipedia/en/e/e4/Beautiful_Bazzi_Camila_Cabello_Single.png" alt="" srcset="">
</a>
</div>
</div>
<div class="col-lg-3 col-md-4 col-sm-6 col-xs-12">
<div class="card m-1">
<a href="#" class="">
Beautiful
<img class="img-fluid" src="https://upload.wikimedia.org/wikipedia/en/2/25/Bazzi_-_Beautiful.jpeg" alt="" srcset="">
</a>
</div>
</div>
<div class="col-lg-3 col-md-4 col-sm-6 col-xs-12">
<div class="card m-1">
<a href="#">
Beautiful
<img class="img-fluid" src="https://upload.wikimedia.org/wikipedia/en/e/e4/Beautiful_Bazzi_Camila_Cabello_Single.png" alt="" srcset="">
</a>
</div>
</div>
<div class="col-lg-3 col-md-4 col-sm-6 col-xs-12">
<div class="card m-1">
<a href="#" class="">
Beautiful
<img class="img-fluid " src="https://upload.wikimedia.org/wikipedia/en/2/25/Bazzi_-_Beautiful.jpeg" alt="" srcset="">
</a>
</div>
</div>
<div class="col-lg-3 col-md-4 col-sm-6 col-xs-12">
<div class="card m-1">
<a href="#">
Beautiful
<img class="img-fluid" src="https://upload.wikimedia.org/wikipedia/en/e/e4/Beautiful_Bazzi_Camila_Cabello_Single.png" alt="" srcset="">
</a>
</div>
</div>
</div>
</div>
I solved this problem using Bootstrap 4 Emdeds Utilities
https://getbootstrap.com/docs/4.3/utilities/embed
In this case you just need to add you image to a div.embbed-responsive like this:
<div class="card"><div class="embed-responsive embed-responsive-16by9"> <img alt="Card image cap" class="card-img-top embed-responsive-item" src="img/butterPecan.jpg" /></div><div class="card-block"><h4 class="card-title">Butter Pecan</h4><p class="card-text">Roasted pecans, butter and vanilla come together to make this wonderful ice cream</p></div></div>
or .card-img-top {width: 100%;}
I am trying to extend the last card-footer to fill the rest of the space if it doesn't have any buttons. I am tried a number of flex combinations without much luck.
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css" rel="stylesheet" />
<div class="row">
<div class="col-4 mb-4">
<div class="card">
<div class="card-header text-center">
<span data-bind="html: TimeFormatted">8:00 AM EST</span>, <span class="venue" data-bind="text: Venue">JB Red Owens, Field 1</span>
</div>
<div class="card-body">
<div class="d-flex">
<div class="text-truncate mr-auto">
<span data-bind="text: AwayTeamName">(A1)</span><span style="display: none;">*</span>
</div>
<div>
<span class="final-score">4</span>
</div>
</div>
<div class="d-flex">
<div class="text-truncate mr-auto">
<span data-bind="text: HomeTeamName">(A2)</span><span style="display: none;">*</span>
</div>
<div>
<span class="final-score">5</span>
</div>
</div>
</div>
<div class="card-footer d-flex">
<div class="text-truncate mr-auto"><span>8U</span>, <span>Pool A</span></div>
<div class="">Final</div>
</div>
<div class="card-footer text-center">
<a target="_blank" title="" href="http://maps.apple.com/maps?daddr=34.8043103,-82.5869584" class="btn btn-sm btn-dark"><i class="fa fa-map-marker"></i> Venue</a>
</div>
</div>
</div>
<div class="col-4">
<div class="card">
<div class="card-header text-center">
<span data-bind="html: TimeFormatted">8:00 AM EST</span>, <span class="venue" data-bind="text: Venue">JB Red Owens, Field 1</span>
</div>
<div class="card-body">
<div class="d-flex">
<div class="text-truncate mr-auto">
<span data-bind="text: AwayTeamName">(A1)</span><span style="display: none;">*</span>
</div>
<div>
<span class="final-score">4</span>
</div>
</div>
<div class="d-flex">
<div class="text-truncate mr-auto">
<span data-bind="text: HomeTeamName">(A2)</span><span style="display: none;">*</span>
</div>
<div>
<span class="final-score">5</span>
</div>
</div>
</div>
<div class="card-footer d-flex">
<div class="text-truncate mr-auto"><span>8U</span>, <span>Pool A</span></div>
<div class="">Final</div>
</div>
<div class="card-footer text-center">
<a target="_blank" title="" href="http://maps.apple.com/maps?daddr=34.8043103,-82.5869584" class="btn btn-sm btn-dark"><i class="fa fa-map-marker"></i> Venue</a>
</div>
</div>
</div>
<div class="col-4">
<div class="card">
<div class="card-header text-center">
<span data-bind="html: TimeFormatted">8:00 AM EST</span>, <span class="venue" data-bind="text: Venue">JB Red Owens, Field 1</span>
</div>
<div class="card-body">
<div class="d-flex">
<div class="text-truncate mr-auto">
<span data-bind="text: AwayTeamName">(A1)</span><span style="display: none;">*</span>
</div>
<div>
<span class="final-score">4</span>
</div>
</div>
<div class="d-flex">
<div class="text-truncate mr-auto">
<span data-bind="text: HomeTeamName">(A2)</span><span style="display: none;">*</span>
</div>
<div>
<span class="final-score">5</span>
</div>
</div>
</div>
<div class="card-footer d-flex">
<div class="text-truncate mr-auto"><span>8U</span>, <span>Pool A</span></div>
<div class="">Final</div>
</div>
<div class="card-footer text-center">
</div>
</div>
</div>
</div>
You could try the following (a part of the solution was retrieved from this answer):
.card {
height: 100%;
}
.card-body {
flex: 0 1 auto !important;
}
.card-footer.text-center {
flex: 1;
}
I have created a small fiddle showing the result:
Good day, I'm using Font-awesome and bootstrap 4. Please check my Script first
<div class="container">
<div class="row">
<div class="col">
<div class="row">
<span class="fa fa-building fa-5x text-center"> </span>
</div>
<div class="row">
<h3 class="text-center">Company Profile</h3>
</div>
</div>
<div class="col">
<div class="row">
<span class="fa fa-shopping-cart fa-5x text-center"> </span>
</div>
<div class="row">
<h3 class="text-center">Shopping Cart</h3>
</div>
</div>
<div class="col">
<div class="row">
<span class="fa fa-industry fa-5x text-center"> </span>
</div>
<div class="row">
<h3 class="text-center">Inventory Control</h3>
</div>
</div>
<div class="col">
<div class="row">
<span class="fa fa-users fa-5x text-center"> </span>
</div>
<div class="row">
<h3 class="text-center">User Management</h3>
</div>
</div>
</div>
</div>
with my script above i get this
as you can see, the fa icons is not at the center of text. How can i make the fa-icon in center ?
Add the text-center class to the div surrounding your icon instead of of the icon span like so:
<div class="row text-center">
<span class="fa fa-users fa-5x"> </span>
</div>
You can simplify your HTML markup to the below and the text under icons will be center aligned based on the class text-center assigned to parent col div.
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<div class="container">
<div class="row">
<div class="col-md-3 text-center">
<span class="fa fa-building fa-5x"> </span>
<h3>Company Profile</h3>
</div>
<div class="col-md-3 text-center">
<span class="fa fa-shopping-cart fa-5x"> </span>
<h3>Shopping Cart</h3>
</div>
<div class="col-md-3 text-center">
<span class="fa fa-industry fa-5x"> </span>
<h3>Inventory Control</h3>
</div>
<div class="col-md-3 text-center">
<span class="fa fa-users fa-5x"> </span>
<h3>User Management</h3>
</div>
</div>
</div>
Simply add the "text-center" class to the "fa" element container:
from:
<div class="row">
<span class="fa fa-building fa-5x text-center"> </span>
to:
<div class="row text-center">
<span class="fa fa-building fa-5x text-center"> </span>
Simply you can add one custom class for making those icons to center align.
You can check this fiddle.
.icon-center{
margin:0 auto;
}
I`m having problems with Bootstrap grid nesting in a project. I've created a div with a grid of 12 and a class with a background image.
After that, I created 3 other grids, one of 3 other with 8 and the last one with 1, for a total of 12. However, when I duplicate it, it doesn`t go to the next line as supposed to..
The link to see it is: https://www.neevasoft.com/test/saude.html
The code is here:
<article id="blog-list" class="blog-list article3 gradient-7">
<div class="container">
<div class="row">
<h2 class="title text-center">Saúde</h2>
<div class="item col-md-12 col-sm-12 col-xs-12">
<div class="item1 col-md-3 col-sm-3 col-xs-3">
<figure class="figure-wrapper">
<a href="interno.html">
<img class="img-responsive2" src="assets/images/blog/blog-1.jpg" alt="">
</a>
</figure>
</div>
<div class="item2 col-md-8 col-sm-8 col-xs-8">
<figure class="figure-wrapper">
<a href="interno.html">
Espaço Corporal Eloiza Bovió
</a>
</figure>
</div>
<div class="item3 col-md-1 col-sm-1 col-xs-1">
<figure class="figure-wrapper">
<a href="interno.html">
<i class="fa fa-angle-right" aria-hidden="true"></i>
</a>
</figure>
</div>
<div class="col-md-3 col-sm-3 col-xs-3">
<figure class="figure-wrapper">
<a href="interno.html">
<img class="img-responsive2" src="assets/images/blog/blog-1.jpg" alt="">
</a>
</figure>
</div>
<div class="col-md-8 col-sm-8 col-xs-8">
<figure class="figure-wrapper">
<a href="interno.html">
Espaço Corporal Eloiza Bovió
</a>
</figure>
</div>
<div class="col-md-1 col-sm-1 col-xs-1">
<figure class="figure-wrapper">
<a href="interno.html">
<i class="fa fa-angle-right" aria-hidden="true"></i>
</a>
</figure>
</div>
</div><!--//row-->
</div><!--//container-->
</article>
You should not be nesting col-* divs
Try using this:
<article id="blog-list" class="blog-list article3 gradient-7">
<div class="container">
<div class="row">
<h2 class="title text-center">Saúde</h2>
<div class="item1 col-md-3 col-sm-3 col-xs-3">
<figure class="figure-wrapper">
<a href="interno.html">
<img class="img-responsive" src="http://lorempixel.com/400/200/" alt="">
</a>
</figure>
</div>
<div class="item2 col-md-8 col-sm-8 col-xs-8">
<figure class="figure-wrapper">
<a href="interno.html">
Espaço Corporal Eloiza Bovió
</a>
</figure>
</div>
<div class="item3 col-md-1 col-sm-1 col-xs-1">
<figure class="figure-wrapper">
<a href="interno.html">
<i class="fa fa-angle-right" aria-hidden="true"></i>
</a>
</figure>
</div>
</div><!--//row-->
<div class="row">
<div class="col-md-3 col-sm-3 col-xs-3">
<figure class="figure-wrapper">
<a href="interno.html">
<img class="img-responsive" src="http://lorempixel.com/400/200/" alt="">
</a>
</figure>
</div>
<div class="col-md-8 col-sm-8 col-xs-8">
<figure class="figure-wrapper">
<a href="interno.html">
Espaço Corporal Eloiza Bovió
</a>
</figure>
</div>
<div class="col-md-1 col-sm-1 col-xs-1">
<figure class="figure-wrapper">
<a href="interno.html">
<i class="fa fa-angle-right" aria-hidden="true"></i>
</a>
</figure>
</div>
</div>
</div><!--//container-->
This is how I managed to fix it
<article id="blog-list" class="blog-list article3 gradient-7">
<div class="container">
<div class="row">
<h2 class="title text-center">Saúde</h2>
<div class="item col-xs-12">
<div class="col-xs-12">
<div class="item1 col-xs-3">
<figure class="figure-wrapper">
<img class="img-responsive2" src="assets/images/blog/blog-1.jpg" alt="">
</figure>
</div>
<div class="item2 col-xs-8">
<figure class="figure-wrapper">
Espaço Corporal Eloiza Bovió
</figure>
</div>
<div class="item3 col-xs-1">
<figure class="figure-wrapper">
<i class="fa fa-angle-right" aria-hidden="true"></i>
</figure>
</div>
</div>
<div class="col-xs-12">
<div class="item1 col-xs-3">
<figure class="figure-wrapper">
<img class="img-responsive2" src="assets/images/blog/blog-1.jpg" alt="">
</figure>
</div>
<div class="item2 col-xs-8">
<figure class="figure-wrapper">
Espaço Corporal Eloiza Bovió
</figure>
</div>
<div class="item3 col-xs-1">
<figure class="figure-wrapper">
<i class="fa fa-angle-right" aria-hidden="true"></i>
</figure>
</div>
</div>
</div>
</div><!--//row-->
</div><!--//container-->
New to bootstrap - have problem with carousel image going over text in nested columns below it. Structure is as follows - not sure why its overlapping nested columns
Would be very grateful for any advice / help
<div class="container-fluid">
<div class="row">
<div class="col-lg-4 col-md-4 col-sm-3 col-xs-3">
<h1 id="logo">test</h1>
</div>
<div class="col-lg-8 col-md-8 col-sm-9 col-xs-9 brownbg">
<div class="row">
<div class="sidebar-nav">
<div class="navbar navbar-default" role="navigation">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".sidebar-navbar-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<span class="visible-xs navbar-brand"></span>
</div>
<div class="navbar-collapse collapse sidebar-navbar-collapse">
<ul class="nav navbar-nav">
<li class="active">menu1</li>
<li>Menu2</li>
</ul>
</div><!--/.nav-collapse -->
</div>
</div>
</div>
<div class="row">
<div id="myCarousel" class="carousel slide" data-ride="carousel">
<div class="carousel-inner" role="listbox">
<div class="item active">
<img src="images/photos/1.jpg" width="771" height="292">
</div>
<div class="item">
<img class="second-slide" src="images/photos/2.jpg" alt="Homeopathy 2">
</div>
</div>
</div><!-- /.carousel -->
</div>
<h2 id="logo2">text</h2>
<div id="menu-line"><!-- -->
<div class="clearfix"></div>
</div>
<div class="clearfix"> </div>
</div>
<div class="clearfix"> </div>
<div class="col-lg-4 col-md-4 col-sm-3 col-xs-3">
</div>
<div class="col-lg-5 col-md-5 col-sm-9-offset-0 col-xs-9 brownbg" id="C1">
text here
<img src="images/img1.png" width="163" height="55" alt=" " style="margin: 20px 0 0 0;" />
</div>
<div class="hidden-lg hidden-md col-sm-3 col-xs-3"></div>
<div class="col-lg-3 col-md-3 col-sm-9 col-xs-9 brownbg" id="C2">
<div style="border-bottom: 2px dashed #000;margin-top:30px;padding:20px 10px;">
<p class="cyan large">Text</p>
<p>text</p>
</div>
</div>
</div>
<div class="row">
<div class="col-lg-4 col-md-4 col-sm-3 col-xs-3">
</div>
<div class="col-lg-5 col-md-5 col-sm-9-offset-0 col-xs-9 footerbg" id="C3">
text
</div>
</div>
<div class="hidden-lg hidden-md col-sm-3 col-xs-3"></div>
</div>
</div>
</div>