I am creating this web portfolio for my web design class with Bootstrap 5. I was able to get my elements to respond correctly for desktop, tablet, and mobile device break points except for the "View More" button on lg screen breakpoint; I simply want to place the same style button underneath the "I'm Nate Finn. Graphic Des...." photo in my desktop version without messing up the order of my photos or sending it down below in which it looks like a footer element. (It currently sits above the footer and looks a bit silly).
I know my columns count is messed up and there is some issue with divs but I cannot figure it out without rearranging everything! I have attached screenshots that included the empty space where I want to center the button:
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap#5.1.3/dist/css/bootstrap.min.css" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<div class="container-fluid">
<div class="row">
<div class="text-end col-lg-7 ps-sm-5 pe-sm-5">
<img class="img-fluid pt-5" src="https://via.placeholder.com/100" alt="Welcome Message">
<img class="img-fluid d-none d-lg-block pt-5 mt-5 ps-sm-2" src="https://via.placeholder.com/100" alt="I'm Nate Finn"></div>
<div class="text-end col-5 order-lg-0 order-md-2 order-2 float-end px-0">
<img class="img-fluid pt-5 py-0 m-0 border-dark" src="https://via.placeholder.com/100" alt="Vector Cartoon of Face and Torso"></div>
<div class="text-center col-7 order-lg-2 d-lg-none order-md-1 order-lg-0 pe-sm-5 ps-sm-5 pt-3">
<img class="img-fluid" src="https://via.placeholder.com/100" alt="I'm Nate Finn">
<button class="btn btn-outline-dark btn-sm fw-bold border-2">View More</button></div>
<div class="container-fluid text-center row-cols-1 d-none d-lg-block px-0">
<button class="btn btn-outline-dark btn-lg order-lg-1 fw-bolder border-3">View More</button></div>
</div>
</div>
<!-- removed by community </section> -->
You could use flexbox on the column, but a simple div wrapper with some top padding works fine to wrap the button below the image.
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap#5.1.3/dist/css/bootstrap.min.css" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<div class="container-fluid">
<div class="row">
<div class="text-end col-lg-7 ps-sm-5 pe-sm-5">
<img class="img-fluid pt-5" src="https://via.placeholder.com/100" alt="Welcome Message">
<img class="img-fluid d-none d-lg-block pt-5 mt-5 ps-sm-2" src="https://via.placeholder.com/100" alt="I'm Nate Finn"></div>
<div class="text-end col-5 order-lg-0 order-md-2 order-2 float-end px-0">
<img class="img-fluid pt-5 py-0 m-0 border-dark" src="https://via.placeholder.com/100" alt="Vector Cartoon of Face and Torso"></div>
<div class="text-center col-7 order-lg-2 d-lg-none order-md-1 order-lg-0 pe-sm-5 ps-sm-5 pt-3">
<img class="img-fluid" src="https://via.placeholder.com/100" alt="I'm Nate Finn">
<div class="mt-3">
<button class="btn btn-outline-dark btn-sm fw-bold border-2">View More</button></div>
</div>
<div class="container-fluid text-center row-cols-1 d-none d-lg-block px-0">
<button class="btn btn-outline-dark btn-lg order-lg-1 fw-bolder border-3">View More</button></div>
</div>
</div>
<!-- removed by community </section> -->
Related
I am unable to figure out what classes should I add/remove to achieve the same image positioning as in the preview of the Bootstrap Border hero with cropped image and shadows.
My image doesn't sit on the edge of the hero and it looks even worst on mobile scale. Here is what my hero looks like now:
<div id="support" class="hero-donate container my-5">
<div class="row p-4 pb-0 pe-lg-0 pt-lg-5 align-items-center rounded-3 border shadow-lg">
<div class="col-lg-7 p-3 p-lg-5 pt-lg-3">
<h1 class="display-4 fw-bold lh-1">Find out more and support our work</h1>
<p class="lead">Text</p>
<div class="d-grid gap-2 d-md-flex justify-content-md-start mb-4 mb-lg-3">
<button type="button" class="btn btn-outline-danger btn-lg px-4 me-md-2 fw-bold">DONATE</button>
<button type="button" class="btn btn-secondary btn-lg px-4">Volunteer</button>
</div>
</div>
<div class="col-lg-4 offset-lg-1 p-0 overflow-hidden">
<img class="rounded-lg-3 shadow-lg" src="https://images.unsplash.com/photo-1608535002897-27b2aa592456?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=870&q=80" alt="" width="75%">
</div>
</div>
</div>
Solutions for both
The image in example is an horizontal image hence it fits perfectly on the right end of div. Your image is vertical so apply this class : float-end on image tag.
For mobile view. Your code works fine only image alignment is distorted. for which apply w-100 and m-auto to image tag. your updated image tag will look like :
<img class="rounded-lg-3 shadow-lg float-end m-auto w-100" src="https://images.unsplash.com/photo-1608535002897-27b2aa592456?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=870&q=80" alt="" width="75%">
here is the working snippet
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.2.3/css/bootstrap.min.css" rel="stylesheet"/>
<div id="support" class="hero-donate container my-5">
<div class="row p-4 pb-0 pe-lg-0 pt-lg-5 align-items-center rounded-3 border shadow-lg">
<div class="col-lg-7 p-3 p-lg-5 pt-lg-3">
<h1 class="display-4 fw-bold lh-1">Find out more and support our work</h1>
<p class="lead">Text</p>
<div class="d-grid gap-2 d-md-flex justify-content-md-start mb-4 mb-lg-3">
<button type="button" class="btn btn-outline-danger btn-lg px-4 me-md-2 fw-bold">DONATE</button>
<button type="button" class="btn btn-secondary btn-lg px-4">Volunteer</button>
</div>
</div>
<div class="col-lg-4 offset-lg-1 p-0 overflow-hidden">
<img class="rounded-lg-3 shadow-lg float-end m-auto w-100" src="https://images.unsplash.com/photo-1608535002897-27b2aa592456?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8" alt="" width="75%">
</div>
</div>
</div>
I am trying to put a button inside the Popovers in Bootstrap. But I did not succeed.
I am using Bootstrap-Popover. I want to have a button inside the popover.
HTML
<div class="col-lg-4 mb-3 servicePOP" data-aos="fade-up" tabindex="0" data-bs-toggle="popover" data-bs-placement="top" data-bs-trigger="focus" title="Title" data-bs-content="A short description">
<div class="card position-relative">
<div class="d-block card-icon">
<img src="images.png" class="card-icon position-absolute start-0 end-0 m-auto rounded-circle mb-5 lazy" alt="Title">
</div>
<div class="card-body text-center mt-5 pt-5">
<a href="# class="text-decoration-none text-dark">
<h5 class="card-title">Title</h5>
</a>
<p>A short description</p>
More Details
</div>
</div>
</div>
JS
<script>
let servicePOP = 'Test link';
$('.servicePOP').popover({
content: servicePOP,
html: true
});
</script>
You need to add sanitize: false option to popover
This question already has answers here:
Bootstrap 4 Cards of same height in columns
(7 answers)
Closed 2 years ago.
First, I'm sorry if there is already an answer to this somewhere. If so, just point me in that direction. I've been looking for a while and can't seem to find an answer that works the way I need.
I am trying to get all of the bootstrap cards on my heroku page to be the same size. I had it set with the container surrounding the responsive divs as display flex and justify-content-center and align-items-center. I have also tried align-items-stretch but it still doesn't result in the cards all being the same height. I've also tried using the bootstrap height utility (h-100) on the responsive divs within the row. Also used css min-height but ran into problems as content would overflow the divs when resizing window.
This is what I currently have that ends up with different sized cards based on the content:
<div class='home-container m-5'>
<div class="row d-flex mb-5 justify-content-center align-items-center">
<div class="col-sm-6 col-lg-4">
<a href='./Multi-welders'>
<div class='card m-3 bg-light'>
<img src="./images/Home/Multi_Welder2.png" alt="ESAB Rebel EMP215IC welder" class="card-img-top pl-md-2 pt-2 pr-md-2 mx-auto">
<div class="card-body text-center">
<h2 class="card-title">Best Multiprocess Welders</h2>
</div>
</div>
</a>
</div>
<div class="col-sm-6 col-lg-4">
<a href='./helmets'>
<div class='card m-3 bg-light'>
<img src="./images/Home/Safety_Equipment2.png" alt="Black welding helmet with red flames" class="card-img-top pl-md-2 pt-2 pr-md-2 mx-auto">
<div class="card-body text-center">
<h2 class="card-title">Best Welding Helmets</h2>
</div>
</div>
</a>
</div>
<div class="col-sm-6 col-lg-4 h-100">
<a href='./gloves'>
<div class='card m-3 bg-light'>
<img src="./images/Home/Welding_Gloves.png" alt="Generic pair of leather welding gloves" class="card-img-top pl-md-2 pt-2 pr-md-2 mx-auto">
<div class="card-body text-center">
<h2 class="card-title">Best Welding Gloves</h2>
</div>
</div>
</a>
</div>
<div class="col-sm-6 col-lg-4">
<div class="card m-3 bg-light">
<img src="./images/Home/MIG_Welder.png" alt="MIG Welder" class="card-img-top pl-md-2 pt-2 pr-md-2 mx-auto coming-soon">
<div class="card-body text-center">
<div class="ribbon ribbon-top-left"><span>Coming Soon</span>
</div>
<h2 class="card-title coming-soon">Best MIG Welders</h2>
</div>
</div>
</div>
<div class="col-sm-6 col-lg-4">
<div class='card m-3 bg-light'>
<img src="./images/Home/Tig Welder2.png" alt="TIG Welder" class="card-img-top pl-md-2 pt-2 pr-md-2 mx-auto coming-soon">
<div class="card-body text-center">
<div class="ribbon ribbon-top-left"><span>Coming Soon</span>
</div>
<h2 class="card-title coming-soon">Best TIG Welders</h2>
</div>
</div>
</div>
<div class='col-sm-6 col-lg-4'>
<div class='card m-3 bg-light'>
<img src="./images/Home/Multi_Welder.png" alt="Professional Welder" class="card-img-top p-3 pl-md-2 pt-2 pr-md-2 mx-auto coming-soon">
<div class="card-body text-center">
<div class="ribbon ribbon-top-left"><span>Coming Soon</span>
</div>
<h2 class="card-title coming-soon">Best Professional Welders</h2>
</div>
</div>
</div>
</div>
</div>
You can add the following css class:
.card {
height: 200px
}
This will give all your cards the same height. You can just change the height to whatever you like.
How to align these 3 div with more margin?
i tried col-3, but still doesn't work for me, i want 1 div to be in left, 2nd in center, and 3rd in right. i tried using css for margin, but it's worse in responsive. do i need to do responsive part to?
Check this image, i want to make this..
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>General Announcement</title>
</head>
<body>
<section class="activities">
<div class="container">
<div class="row">
<div class="col-md-12">
<h3 class="text-center text-primary text-uppercase font-weight-bold mb-4">Upcoming activities for october 2019</h3>
</div>
<div class="col-md-3 mb-sm-5">
<img src="images/img-5.jpg" class="img-fluid">
<span class="d-block text-uppercase font-weight-bold mt-3">October 20</span>
<h4 class="text-uppercase font-weight-bold">Run for charity</h4>
More info
</div>
<div class="col-md-3 mb-sm-5">
<img src="images/img-6.jpg" class="img-fluid">
<span class="d-block text-uppercase font-weight-bold mt-3">October 11</span>
<h4 class="text-uppercase font-weight-bold">Book drive</h4>
More info
</div>
<div class="col-md-3">
<img src="images/img-7.jpg" class="img-fluid">
<span class="d-block text-uppercase font-weight-bold mt-3">October 21</span>
<h4 class="text-uppercase font-weight-bold">Recycling initiative</h4>
More info
</div>
</div>
</div>
</section>
</body>
</html>
Move the col-12 header part outside of what is now your row and change row to be a flex column. BS4 supports flex and it's the best way to go for this use case.
Here's a fiddle
<section class="activities">
<div class="container">
<div class="col-md-12">
<h3 class="text-center text-primary text-uppercase font-weight-bold mb-4">Upcoming activities for october 2019</h3>
</div>
<div class="d-flex justify-content-between">
<div class="col-md-3 mb-sm-5">
<img src="images/img-5.jpg" class="img-fluid">
<span class="d-block text-uppercase font-weight-bold mt-3">October 20</span>
<h4 class="text-uppercase font-weight-bold">Run for charity</h4>
More info
</div>
<div class="col-md-3 mb-sm-5">
<img src="images/img-6.jpg" class="img-fluid">
<span class="d-block text-uppercase font-weight-bold mt-3">October 11</span>
<h4 class="text-uppercase font-weight-bold">Book drive</h4>
More info
</div>
<div class="col-md-3">
<img src="images/img-7.jpg" class="img-fluid">
<span class="d-block text-uppercase font-weight-bold mt-3">October 21</span>
<h4 class="text-uppercase font-weight-bold">Recycling initiative</h4>
More info
</div>
</div>
</div>
</section>
You need to include Bootstrap css.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>General Announcement</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css"
integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
</head>
<body>
<section class="activities">
<div class="container">
<div class="row justify-content-between">
<div class="col-md-12">
<h3 class="text-center text-primary text-uppercase font-weight-bold mb-4">Upcoming activities for
october 2019</h3>
</div>
<div class="col-md-3 mb-sm-5">
<img src="images/img-5.jpg" class="img-fluid">
<span class="d-block text-uppercase font-weight-bold mt-3">October 20</span>
<h4 class="text-uppercase font-weight-bold">Run for charity</h4>
More info
</div>
<div class="col-md-3 mb-sm-5">
<img src="images/img-6.jpg" class="img-fluid">
<span class="d-block text-uppercase font-weight-bold mt-3">October 11</span>
<h4 class="text-uppercase font-weight-bold">Book drive</h4>
More info
</div>
<div class="col-md-3">
<img src="images/img-7.jpg" class="img-fluid">
<span class="d-block text-uppercase font-weight-bold mt-3">October 21</span>
<h4 class="text-uppercase font-weight-bold">Recycling initiative</h4>
More info
</div>
</div>
</div>
</section>
</body>
</html>
try this I hope this will work :)
I've got a questtion about the Bootstrap Card Deck.
I create a Card Deck with two cards in a row. On the first card I've got some text under the header and in the second card there is no text under the header. In this case the grey color does not fill the whole card as you can see in the example. How can I fix it, that the hole column is also grey?
Thanks for your help!
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.4.1/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/mdbootstrap/4.11.0/css/mdb.min.css">
<div class="card-deck mb-5">
<a href="#" class="card hoverable">
<div class="card-body p-0">
<div class="row mx-0">
<div class="col-md-8 grey lighten-4 rounded-left pt-2">
<h5 class="font-weight-bold">Header</h5>
<p class="font-weight-light text-muted mb-2">Some text</p>
</div>
<div class="col-md-4 text-center pt-3">
<p class="h2 font-weight-normal">60</p>
</div>
</div>
</div>
</a>
<a href="#" class="card hoverable">
<div class="card-body p-0">
<div class="row mx-0">
<div class="col-md-8 grey lighten-4 rounded-left pt-2">
<h5 class="font-weight-bold">Header</h5>
<!-- <p class="font-weight-light text-muted mb-2">No text</p> -->
</div>
<div class="col-md-4 text-center pt-3">
<p class="h2 font-weight-normal">50</p>
</div>
</div>
</div>
</a>
</div>
If you want to have the height be equals the container, you can use h-100 on the div row mx-0.
More information can be found here: https://getbootstrap.com/docs/4.0/utilities/sizing/
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.4.1/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/mdbootstrap/4.11.0/css/mdb.min.css">
<div class="card-deck mb-5">
<a href="#" class="card hoverable">
<div class="card-body p-0">
<div class="row mx-0">
<div class="col-md-8 grey lighten-4 rounded-left pt-2">
<h5 class="font-weight-bold">Header</h5>
<p class="font-weight-light text-muted mb-2">Some text</p>
</div>
<div class="col-md-4 text-center pt-3">
<p class="h2 font-weight-normal">60</p>
</div>
</div>
</div>
</a>
<a href="#" class="card hoverable">
<div class="card-body p-0">
<div class="row h-100 mx-0">
<div class="col-md-8 grey lighten-4 rounded-left pt-2">
<h5 class="font-weight-bold">Header</h5>
<!-- <p class="font-weight-light text-muted mb-2">No text</p> -->
</div>
<div class="col-md-4 text-center pt-3">
<p class="h2 font-weight-normal"></p>
</div>
</div>
</div>
</a>
</div>
Ideally you should not play around with left/right margins of row and col in bootstrap. You should use no-gutters class with row to have the effect you want. Additionally, you should add h-100 on the second row to take full height. Also a better way to center align your number is like I have done in the snippet by using justify-content-center d-flex align-items-center.
Also your code was missing a container element so that scrollbar was coming in your snippet. I have added that too.
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.4.1/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/mdbootstrap/4.11.0/css/mdb.min.css">
<div class="container">
<div class="card-deck mb-5">
<a href="#" class="card hoverable">
<div class="card-body p-0">
<div class="row h-100 no-gutters">
<div class="col-md-8 grey lighten-4 rounded-left">
<h5 class="font-weight-bold p-2">Header</h5>
<p class="font-weight-light text-muted mb-2 px-2">Some text</p>
</div>
<div class="col-md-4 text-center justify-content-center d-flex align-items-center">
<p class="h2 font-weight-normal">60</p>
</div>
</div>
</div>
</a>
<a href="#" class="card hoverable">
<div class="card-body p-0">
<div class="row h-100 no-gutters">
<div class="col-md-8 grey lighten-4 rounded-left">
<h5 class="font-weight-bold p-2">Header</h5>
<!-- <p class="font-weight-light text-muted mb-2 px-2">No text</p> -->
</div>
<div class="col-md-4 text-center justify-content-center d-flex align-items-center">
<p class="h2 font-weight-normal">50</p>
</div>
</div>
</div>
</a>
</div>
</div>
Please check the code differences https://i.stack.imgur.com/0Q2IX.png
Using anchor tag as it will not consider a height and width so you have to set a class in card-body using this class="card-body p-0 grey lighten-4".
Remove the class "grey lighten-4" from class="col-md-8 rounded-left pt-2" & set to class="card-body p-0 grey lighten-4"
.grey {
background-color: #f5f5f5 !important;
}
/*OR*/
.grey.lighten-4 {
background-color: #f5f5f5 !important;
}
<div class="card-deck mb-5">
<a href="#" class="card hoverable">
<div class="card-body p-0 grey lighten-4">
<div class="row mx-0">
<div class="col-md-8 rounded-left pt-2">
...
</div>
<div class="col-md-4 text-center pt-3">
...
</div>
</div>
</div>
</a>
</div>