Spread out Bootstrap images with captions within a column - css

I have a pricing comparison section of a Bootstrap 5 website, one column displays the images perfectly (without captions), however whenever I add a paragraph tag for the caption, the images stack on top of one another instead of staying inline in a row.
Here is the code for images without captions:
<div class="col-lg-4 col-md-6" data-aos="zoom-in" data-aos-delay="150">
<div class="box">
<h3>Basic</h3>
<h4><sup>£</sup>4.50<span> / month</span></h4>
<ul>
<li><i class="bi bi-check-circle"></i>Web and mobile versions of Office apps only</li>
<li><i class="bi bi-check-circle"></i>Chat, call, meet up to 300 attendees</li>
<li><i class="bi bi-check-circle"></i>1 TB of cloud storage per user</li>
<li><i class="bi bi-check-circle"></i>Business-class email</li>
<li><i class="bi bi-check-circle"></i>Standard security</li>
<li><i class="bi bi-check-circle"></i>Anytime phone and web support</li>
</ul>
<p>Web and mobile apps and services:</p>
<img src="assets/img/Word_64x64.png" alt="" class="img-fluid">
<img src="assets/img/Excel_64x64.png" alt="" class="img-fluid">
<img src="assets/img/Outlook_64x64.png" alt="" class="img-fluid">
<img src="assets/img/PowerPoint_64x64.png" alt="" class="img-fluid">
<img src="assets/img/Microsoft_Teams_64x64.png" alt="" class="img-fluid">
<img src="assets/img/Outlook_64x64.png" alt="" class="img-fluid">
<img src="assets/img/Exchange_64x64.png" alt="" class="img-fluid">
<img src="assets/img/OneDrive_64x64.png" alt="" class="img-fluid">
<img src="assets/img/SharePoint_64x64.png" alt="" class="img-fluid">
<div class="btn-wrap">
Buy Now
</div>
</div>
</div>
Here is the code for images with captions:
<div class="col-lg-4 col-md-6 mt-4 mt-lg-0" data-aos="zoom-in" data-aos-delay="150">
<div class="box featured">
<h3>Premium</h3>
<h4><sup>£</sup>16.60<span> / month</span></h4>
<b><p>Everything in Business Standard, plus:</p></b>
<ul>
<li><i class="bi bi-check-circle white"></i>Advanced security
<li><i class="bi bi-check-circle white"></i>Access and data control
<li><i class="bi bi-check-circle white"></i>Cyberthreat protection</li>
<li><i class="bi bi-check-circle white"></i>Mobile device management</li>
</ul>
<p>Desktop, web, and mobile apps and services:</p>
<img src="assets/img/Excel_64x64.png" alt="" class="img-fluid"><p>Excel</p>
<img src="assets/img/Outlook_64x64.png" alt="" class="img-fluid"><p>Outlook</p>
<img src="assets/img/PowerPoint_64x64.png" alt="" class="img-fluid"><p>PowerPoint</p>
<img src="assets/img/Microsoft_Teams_64x64.png" alt="" class="img-fluid"><p>Teams</p>
<img src="assets/img/Outlook_64x64.png" alt="" class="img-fluid"><p>Outlook</p>
<img src="assets/img/Exchange_64x64.png" alt="" class="img-fluid"><p>Exchange</p>
<img src="assets/img/OneDrive_64x64.png" alt="" class="img-fluid"><p>OneDrive</p>
<img src="assets/img/SharePoint_64x64.png" alt="" class="img-fluid"><p>SharePoint</p>
<img src="assets/img/Access_64x64.png" alt="" class="img-fluid"><p>Access</p>
<img src="assets/img/Publisher_64x64.png" alt="" class="img-fluid"><p>Publisher</p>
<div class="btn-wrap">
Buy Now
</div>
</div>
</div>
What do I need to change to keep the icons inline?

Try wrapping your <img> and the <p> inside a <div>. Since <p> is a block-level element, meaning that any element after <p> will automatically be added to a new line.
Here's my example
<div>
<img/>
<span>your text here</span>
</div>
Also note that I'm changing <p> with <span>

Update code
To centre all the content
<div class="d-flex flex-wrap align-items-center justify-content-center">
...
</div>
Try to use the flex property of bootstrap
<div class="d-flex flex-column align-items-center justify-content-center">
<img/>
<p>your text here</p>
</div>
for more details check out the bootstrap doc[https://getbootstrap.com/docs/5.0/utilities/flex/]
and You can wrap all the image div with flex-wrap
<div class="d-flex flex-wrap">
...
</div>

Related

I cannot put each object side by side

With the reference to the subject, I cannot put each object which should be bracketed by the i tag. I would like to align it side by side. However I used a li tag and float:left and right on CSS, it was not changed. Does anyone know how to change the position?
<section id="mypassion-section" class="bg-light text-muted py-5">
<div class="container">
<div class="row">
<div class="col-md-4 text-center">
<img src="img/logo.png" width="100px" height="100px" alt="" class="img-fluid mb-3 rounded-circle">
<h3>生徒さんの成長</h3>
<p>OOOOO様 <br>受講前</p>
<i class="fa fa-play icon-left" aria-hidden="true"></i>
<p>受講後</p>
<i class="fa fa-play icon-right" aria-hidden="true"></i>
</div>
I used bootstrap classes to align items without changing much in DOM. Please check on the link to get more knowledge on Bootstrap Classes.
<link href="https://cdn.jsdelivr.net/npm/bootstrap#4.5.3/dist/css/bootstrap.min.css" rel="stylesheet"/>
<link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>
<section id="mypassion-section" class="bg-light text-muted py-5">
<div class="container">
<div class="row">
<div class="col-md-4 text-center">
<img src="https://via.placeholder.com/100x100.png?text=Logo" width="100px" height="100px" alt="" class="img-fluid mb-3 rounded-circle">
<h3>生徒さんの成長</h3>
<p>OOOOO様 <br>受講前</p>
<div class="d-flex align-items-center justify-content-center">
<i class="fa fa-play fa-rotate-180 icon-left" style="margin-right: 1rem;" aria-hidden="false"></i>
<p class="mb-0">受講後</p>
<i class="fa fa-play icon-right" style="margin-left: 1rem;" aria-hidden="false"></i>
</div>
</div>
</div>
</div>
</section>
Was there a reason you didn’t want to put the icons in the p tag?
<link href="https://cdn.jsdelivr.net/npm/bootstrap#4.5.3/dist/css/bootstrap.min.css" rel="stylesheet"/>
<link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>
<section id="mypassion-section" class="bg-light text-muted py-5">
<div class="container">
<div class="row">
<div class="col-md-4 text-center">
<img src="https://via.placeholder.com/100x100.png?text=Logo" width="100px" height="100px" alt="" class="img-fluid mb-3 rounded-circle">
<h3>生徒さんの成長</h3>
<p>OOOOO様 <br>受講前</p>
<p><i class="fa fa-play fa-rotate-180 icon-left" style="margin-right: 1rem;" aria-hidden="false"></i>
受講後
<i class="fa fa-play icon-right" style="margin-left: 1rem;" aria-hidden="false"></i></p>
</div>
</div>
</div>
</section>
It was good that you included some code in your question, but it's better to use the snippet tool to include things like the Bootstrap and Font Awesome CSS files and to provide a running example of what you have so far.

images with different size at the center of the cards in Bootstrap

I have the following HTML code to put a list of organization's logos and links inside card.
Whenever I add a logo, card size change in according to logo size and image not centered inside card.
I have used class = mx-auto and class = card-block but didnt work out.
<section class="site-section" id="section-blog">
<div class="container">
<div class="row mt-5 justify-content-center">
<div class="card card-custom mx-2 mb-3">
<a href="https://www.netflix.com/fr/">
<img src="https://cdn1.iconfinder.com/data/icons/metro-ui-dock-icon-set--icons-by-dakirby/256/Netflix.png"
alt="" class="mx-auto">
</a>
</div>
<div class="card card-custom mx-2 mb-3">
<a href="https://www.hulu.com">
<img src="https://apprecs.com/ios-meta/app-icons/256/376510438.jpg" alt=""
class="card-img">
</a>
</div>
<div class="card card-custom mx-2 mb-3">
<a href="https://www.netflix.com/fr/">
<img src="https://cdn1.iconfinder.com/data/icons/metro-ui-dock-icon-set--icons-by-dakirby/256/Netflix.png"
alt="" class="card-img">
</a>
</div>
<div class="card card-custom mx-2 mb-3">
<a href="https://www.hulu.com">
<img src="https://apprecs.com/ios-meta/app-icons/256/376510438.jpg" alt=""
class="card-img">
</a>
</div>
</div>
</div>
</section>
I checked your code and everything seems to be working, except the first card element and its image. The image should have a class of card-img. Be sure to check the JSFiddle demo. Maybe the issue is in the bootstrap link you are using

How to use Bootstrap grid system to div?

I am designing the asp.net bootstrap form. I have one div in it.
Code:
<div id="gallery">
<a href="aboutus.aspx">
<img src="images/layout/exportsatdubai.jpg" class="img-responsive" width="900" title="" alt="" rel="a" />
</a>
<a href="http://expogr.com/" target="_blank">
<img src="images/layout/777x282-africa-1.jpg" class="img-responsive" width="900" title="" alt="" rel="a" />
</a>
<a href="addlisting.aspx">
<img src="images/layout/becomeAMember.jpg" class="img-responsive" width="900" title="" alt="" rel="a" />
</a><a href="dubaiexhibitions.aspx">
<img src="images/layout/dubaiexportersexhibitions.jpg" class="img-responsive" width="1000" title="" alt=""
rel="a" />
</a>
</div>
Css:
#gallery
{
position: relative;
height: 282px;
}
I wanted to make this div responsive using Bootstrap grid system. I am confused with div ie. How to apply grid system on div?
<div class="row">
<div class="col-sm-12">
<div class="gallery">
------contents------
</div>
</div>
</div>
Is it like this? I am new to Bootstrap. I just wanted to know how to apply grid system to div.
You can use the bootstrap grid like this.
<div class="container">
<div class="row">
<div class="col-lg-3 col-md-3 col-sm-6 col-xs-12">
<a href="aboutus.aspx">
<img src="images/layout/exportsatdubai.jpg" class="img-responsive" alt="" rel="a" />
</a>
</div>
<div class="col-lg-3 col-md-3 col-sm-6 col-xs-12">
<a href="http://expogr.com/" target="_blank">
<img src="images/layout/777x282-africa-1.jpg" class="img-responsive" alt="" rel="a" />
</a>
</div>
<div class="col-lg-3 col-md-3 col-sm-6 col-xs-12">
<a href="addlisting.aspx">
<img src="images/layout/becomeAMember.jpg" class="img-responsive" alt="" rel="a" />
</a>
</div>
<div class="col-lg-3 col-md-3 col-sm-6 col-xs-12">
<a href="dubaiexhibitions.aspx">
<img src="images/layout/dubaiexportersexhibitions.jpg" class="img-responsive" alt="" rel="a" />
</a>
</div>
</div>
</div>
You can follow this link for further details. Bootstrap Grid
A general way to use grid system is
<div class="container">
<div class="row">
<div class="col-sm-3">Content1</div>
<div class="col-sm-3">Content2</div>
<div class="col-sm-3">Content3</div>
<div class="col-sm-3">Content4</div>
</div>
</div>
Every column will have equal width and it will act responsive. You don't need to set height or width of divs inside these columns unless you intentionally want it. If you can provide more details what exactly do you want , i can try to help more.
you can use the grid system of 12 spans and as many rows as you want as you have different spanning of images for different rows like this:
<div class="container">
<div class="row">
<div class="col-xs-12 col-md-12"></div>
<a href="aboutus.aspx">
<img src="images/layout/exportsatdubai.jpg" class="img-responsive" alt=""/>
</a>
</div>
<div class="row">
<div class="col-xs-6 col-md-6">...</div>
<div class="col-xs-6 col-md-6">...</div>
</div>
<div class="row">
<div class="col-xs-6 col-md-6">...</div>
<div class="col-xs-6 col-md-6">.....</div>
</div>
.....
.....
and so on
</div>

Bootstrap carousel Hyperlinks not working

am trying to have a carousel where each slide is linked to a different page.
My code for the base carousel is
<!-- Wrapper for slides -->
<div class="carousel-inner" role="listbox">
<div class="item active">
<a href="about.html">
<img src="img//tshirts/large/slide1.png" alt="" >
</div>
<div class="item">
<a href="tshirts.html">
<img src="img//tshirts/large/slide2.png" alt="">
</div>
<div class="item">
<a href="sublimation.html">
<img src="img//tshirts/large/slide3.png" alt="">
</div>
<div class="item">
<a href="sweatshirts.html">
<img src="img//tshirts/large/slide4.png" alt="">
</div>
</div>
This works perfect and shows all 4 slides one after another then back to beginning
So I wanted to add the hyperlinks as follows
<!-- Wrapper for slides -->
<div class="carousel-inner" role="listbox">
<div class="item active">
<a href="about.html">
<img src="img//tshirts/large/slide1.png" alt="" >
</div>
<div class="item">
<a href="tshirts.html">
<img src="img//tshirts/large/slide2.png" alt="">
</div>
<div class="item">
<a href="sublimation.html">
<img src="img//tshirts/large/slide3.png" alt="">
</div>
<div class="item">
<a href="sweatshirts.html">
<img src="img//tshirts/large/slide4.png" alt="">
</div>
</div>
Now when I run the second code the first slide is perfect and when clicked goes to the page but as soon as it slides to the next slide no slide is shown and none are clickable and it doesn't go back to the first slide
Please close hyper link tag, Like
<div class="item active">
<a href="about.html">
<img src="img//tshirts/large/slide1.png" alt="" >
</a>
</div>

Why is the col-md-4 column starting from the right and leaving a blank space on next line

I am displaying a list of search results. I am using col-md-4 from bootstrap to display 3 results per row - a bit like 3 cards. However when it moves to the next row it starts from the right and then the next item shows up only on the next one left... basically jumping a column.
Following code to be repeated as many time as needed. End goal is to display results like a grid.
<div class="outer-listings-container row-space-8">
<div class="row row-condensed listings-container">
<!-- PART TO REPEAT -->
<div class="col-md-4 row-space-1" data-id="36">
<div class="result">
<div class="panel-image listing-img">
<div id="36" class="carousel slide" data-ride="carousel">
<div class="carousel-inner" role="listbox">
<div class="item active">
<a class="center-block" href="#">
<div class="center-block">
<img class="img-responsive center-block" src="#"> </div>
</a>
</div>
<div class="item">
<a class="" href="#">
<div class="center-block">
<img class="img-responsive center-block" src="#">
</div>
</a>
</div>
</div>
<div>
<a class="left carousel-control height-test" id="36" href="#36" role="button" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left"></span>
<span class="sr-only">Previous</span>
</a>
</div>
<div>
<a class="right carousel-control height-test" id="36" href="#36" role="button" data-slide="next">
<span class="glyphicon glyphicon-chevron-right"></span>
<span class="sr-only">Next</span>
</a>
</div>
</div>
<div class="panel-overlay-bottom-left panel-overlay-label panel-overlay-listing-label">
<div>
<sup class="h6">€</sup>
<span class="h3">456</span>
<sup class="h6">EUR</sup>
<span class="h6">/session of 2 hours</span>
</div>
</div>
</div>
<div class="panel-body panel-body-result">
<h4>
<div class="row">
<div class="col-xs-2">
<img src="#" class="avatar-sm" alt="Banana"> </div>
<div class="col-xs-10">
Banana R
<br>
<small>Banana R</small>
</div>
</div>
</h4>
<span class="stars2"><span style="width: 0px;"></span></span>
<span><b class="review_score">0</b> (0 reviews)</span>
<p>blabla</p>
<p>more blabla </p>
</div>
</div>
</div>
<!-- END REPEAT -->
</div>
</div>
Problem can be seen on the following page: https://gokyma.com/search?location=Paris%2C+France&country=FR&city=Paris&state=IDF&stype=5&selected_date=&selected_time=&_token=ZHXfiseRlAgE3fLY0f1ywr7qYzj9eFxGkSZ2SFIS
Well, your jsfiddle code is not really representative of the issue, but I guess one solution could be adding <div class="row"></div> for each series of 3 col-md-4 that you have in each line. So, the snippet would look something like this;
<row> <col-md-4> <col-md-4> <col-md-4> </row>
Remember, a row can't contain more than 12 columns.... that's another thing to take into consideration...

Resources