I'm trying to make a "products" page, I have a card in each column, and only one row.
<section>
<div class="container">
<div class="row">
<div class="col s12">
<h4 class="grey-text text-darken-4">
New Listings
</h4>
</div>
</div>
<div class="row">
<div class="col s6 m4 l3">
<div class="card hoverable">
<a href="">
<div class="card-image">
<img src="https://source.unsplash.com/250x250/?mobile" alt="" />
</div>
<div class="card-content">
<h6 class="truncate black-text"><b>Lorem</b></h6>
<p class="truncate grey-text text-darken-2">Buy Lorem</p>
<p class="right-align grey-text"><small>Today</small></p>
</div>
</a>
</div>
</div>
<div class="col s6 m4 l3">
<div class="card hoverable">
<a href="">
<div class="card-image">
<img src="https://source.unsplash.com/250x250/?mobile" alt="" />
</div>
<div class="card-content">
<h6 class="truncate black-text"><b>Lorem</b></h6>
<p class="truncate grey-text text-darken-2">Buy Lorem</p>
<p class="right-align grey-text"><small>Today</small></p>
</div>
</a>
</div>
</div>
<div class="col s6 m4 l3">
<div class="card hoverable">
<a href="">
<div class="card-image">
<img src="https://source.unsplash.com/250x250/?mobile" alt="" />
</div>
<div class="card-content">
<h6 class="truncate black-text"><b>Lorem</b></h6>
<p class="truncate grey-text text-darken-2">Buy Lorem</p>
<p class="right-align grey-text"><small>Today</small></p>
</div>
</a>
</div>
</div>
</div>
</div>
</section>
My code looks something like this, a card jumps from one line to the next even though there is space for it, I don't really know what is wrong
Edit: It is working now, gave a class "small" to card div. Thanks to Sean.
Materialize rows don't handle cards with different heights very well, for this scenario, it helps to fix the height of your cards to make them uniform using the three provided classes:|
<div class="card small">
<!-- Card Content -->
</div>
Three sizes applied as an extra class on the card - small, medium and large which equate to:
.card.small {
height: 300px;
}
.card.medium {
height: 400px;
}
.card.large {
height: 500px;
}
https://materializecss.com/cards.html#sizes
Related
I'm trying to build a portfolio with bootstrap cards where images are also required to be displayed.
Problem is that images are not contained properly within bootstrap card around corners(with class="card-img-top") like some cards are not rounded or some images are not rounded but cards are rounded(tried class="img-rounded").
Kindly zoom in on the images to see the difference. Below are some snippets (and code is given below the snippets):-
Perfect card with image:-
Yellow-> difference
Bug-1:-
Bug-2:-
Bug-3:-
Bug-4:-
Code:-
<%- include('partials/headHTML') %>
<link rel="stylesheet" href="/css/tourpackageStyles.css">
</head>
<!-- <%- include('partials/header') %> -->
<div class="Container">
<div class="container-fluid">
<div class="row">
<div class="col col-md-4">
<div class="card h-100">
<img src="https://cdn.pixabay.com/photo/2022/06/05/20/24/rome-7244828_960_720.jpg" alt="" class="card-img-top">
<div class="card-body">
<div class="card-title">Title-1</div>
</div>
<a target="_blank" rel="noopener noreffer" href="#" role="button"
class="btn btn-sm btn-secondary">Enquire</a>
</div>
</div>
<div class="col col-md-4">
<div class="card h-100">
<img src="/images/wildlife/wildlife_tour.jpg"
alt=""
class="card-img-top">
<div class="card-body">
<div class="card-title">Title- 2</div>
</div>
<a target="_blank" rel="noopener noreffer" href="#"
class="btn btn-sm btn-secondary">Enquire</a>
</div>
</div>
</div>
</div>
<div class="container-fluid">
<div class="row row-cols-1 row-cols-md-3 row-cols-sm-2 gy-3">
<div class="col">
<div class="card h-100">
<img src="https://cdn.pixabay.com/photo/2022/06/05/20/24/rome-7244828_960_720.jpg" alt="" class="card-img-top">
<div class="card-body">
<div class="card-title">
Title- 3
</div>
</div>
</div>
</div>
<div class="col">
<div class="card h-100">
<img src="https://cdn.pixabay.com/photo/2022/06/05/20/24/rome-7244828_960_720.jpg" alt="" class="card-img-top">
<div class="card-body">
<div class="card-title">
Title- 4
</div>
</div>
</div>
</div>
<div class="col">
<div class="card h-100">
<img src="https://cdn.pixabay.com/photo/2022/06/05/20/24/rome-7244828_960_720.jpg" alt="" class="card-img-top">
<div class="card-body">
<div class="card-title">
Title- 5
</div>
</div>
</div>
</div>
<div class="col">
<div class="card h-100">
<img src="" alt="">
<div class="card-body">
<div class="card-title">
Title- 6
</div>
</div>
</div>
</div>
<div class="col">
<div class="card h-100">
<img src="" alt="">
<div class="card-body">
<div class="card-title">
Title- 7
</div>
</div>
</div>
</div>
<div class="col">
<div class="card h-100">
<img src="" alt="">
<div class="card-body">
<div class="card-title">
Title- 8
</div>
</div>
</div>
</div>
</div>
</div>
</div>
If you wish to display only image while using card then place image inside card-body to achieve what you want and give card class "overflow-hidden". Because if you use "card-img-top" and then it has only border-top-left-radius and border-top-right-radius so image wouldn't be rounded on bottom.so you have to provide border-radius manually to both bottom side.
<div class="card overflow-hidden">
<div class="card-body">
<img class="img-fluid" src="" alt="">
</div>
</div>
For more information refer official docs https://getbootstrap.com/docs/5.2/components/card/
In a webpage I have this two columns with a picture and some text below. One of the texts is longer than the other which makes the text box longer than the other.
How do I do some padding to make the columns even in a elegant way?
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet"/>
<div class="col-sm-6 col-lg-4 col-xl-3 mb-4 mb-xl-0">
<div class="card card-subject">
<div class="card-subject__img">
<img class="card-img rounded-0" src="img/home/subject-1.png" alt="">
<div class="card-subject__imgOverlay">
<img src="img/home/hover-icon.png" alt="">
</div>
</div>
<div class="card-subject__body">
<h3>Employment Law</h3>
<p>This Text i longer than the one This Text i longer than the onenext to it Dominion there fifth fowl eving heaven in life you're over us moved creepeth morn make</p>
</div>
</div>
</div>
<div class="col-sm-6 col-lg-4 col-xl-3 mb-4 mb-xl-0">
<div class="card card-subject">
<div class="card-subject__img">
<img class="card-img rounded-0" src="img/home/subject-2.png" alt="">
<div class="card-subject__imgOverlay">
<img src="img/home/hover-icon.png" alt="">
</div>
</div>
<div class="card-subject__body">
<h3>Personal Injury</h3>
<p>Dominion there fifth fowl eving heaven in life you're over us moved creepeth morn make</p>
</div>
</div>
</div>
.card{
height:60vw;
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet"/>
<div class="col-sm-6 col-lg-4 col-xl-3 mb-4 mb-xl-0">
<div class="card card-subject">
<div class="card-subject__img">
<img class="card-img rounded-0" src="img/home/subject-1.png" alt="">
<div class="card-subject__imgOverlay">
<img src="img/home/hover-icon.png" alt="">
</div>
</div>
<div class="card-subject__body">
<h3>Employment Law</h3>
<p>This Text i longer than the one This Text i longer than the onenext to it Dominion there fifth fowl eving heaven in life you're over us moved creepeth morn make</p>
</div>
</div>
</div>
<div class="col-sm-6 col-lg-4 col-xl-3 mb-4 mb-xl-0">
<div class="card card-subject">
<div class="card-subject__img">
<img class="card-img rounded-0" src="img/home/subject-2.png" alt="">
<div class="card-subject__imgOverlay">
<img src="img/home/hover-icon.png" alt="">
</div>
</div>
<div class="card-subject__body">
<h3>Personal Injury</h3>
<p>Dominion there fifth fowl eving heaven in life you're over us moved creepeth morn make</p>
</div>
</div>
</div>
Why are my bootstrap cards aligned on top of each other and not side by side across the page ?
This is the html I have. The rest of the webside is working fine. Not sure what the issue is with these cards and why they will not align side by side.
<div class="container-fluid padding">
<div id="row" class="row padding">
<div class="col-md-4">
<div class="card">
<img class="card-img-top" src="grow.png">
<div class="card-body">
<h4 class="card-title">John Doe</h4>
<p>This is just going to be information about about
the company and wh
</p>
See Profile
</div>
</div>
</div>
</div>
<div class="col-md-4">
<div class="card">
<img class="card-img-top" src="grow.png">
<div class="card-body">
<h4 class="card-title">John Doe</h4>
<p>This is just going to be information about about
the company and wh
</p>
See Profile
</div>
</div>
</div>
<div class="col-md-4">
<div class="card">
<img class="card-img-top" src="grow.png">
<div class="card-body">
<h4 class="card-title">John Doe</h4>
<p>This is just going to be information about about
the company and wh
</p>
See Profile
</div>
</div>
</div>
</div>
You forgot to close your div tag. This should work.
<div class="container-fluid padding">
<div id="row" class="row padding">
<div class="col-md-4">
<div class="card">
<img class="card-img-top" src="grow.png" />
<div class="card-body">
<h4 class="card-title">John Doe</h4>
<p>
This is just going to be information about about the company and
wh
</p>
See Profile
</div>
</div>
</div>
<div class="col-md-4">
<div class="card">
<img class="card-img-top" src="grow.png" />
<div class="card-body">
<h4 class="card-title">John Doe</h4>
<p>
This is just going to be information about about the company and
wh
</p>
See Profile
</div>
</div>
</div>
<div class="col-md-4">
<div class="card">
<img class="card-img-top" src="grow.png" />
<div class="card-body">
<h4 class="card-title">John Doe</h4>
<p>
This is just going to be information about about the company and
wh
</p>
See Profile
</div>
</div>
</div>
</div>
</div>
I want the three images to be side-by-side (on desktop), with the headings and paragraph text to be beneath each respective image.
Does anyone know why it wouldn't be working for me? I presume my code is incorrect somehow
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
<div class="portfolio-container">
<section class="portfolio">
<div class="row">
<div class="col-12 my-5">
<h2 class="text-uppercase">Portfolio</h2>
</div>
</div>
<div class="row">
<div class="col-12 col-md-6 col-lg-4">
<div class="media">
<div class="d-none d-sm-block">
<img src="images/whiskey-drop.png" class="rounded-circle mr-3" height=50 width=50>
</div>
<div class="media-body">
<h3>Whiskey Drop</h3>
<h4>HTML, CSS, Bootstrap</h4>
<p>An e-commerce website for a premium whiskey service.</p>
</div>
</div>
</div>
<div class="row">
<div class="col-12 col-md-6 col-lg-4">
<div class="media">
<div class="d-none d-sm-block">
<img src="images/rosie-odenkirk.png" class="rounded-circle mr-3" height=50 width=50>
</div>
<div class="media-body">
<h3>Resume</h3>
<h4>HTML, CSS, Bootstrap</h4>
<p>A responsive and user friendly resume showcasing a sample candidate in the best light possible.</p>
</div>
</div>
</div>
<div class="row">
<div class="col-12 d-md-none d-lg-block col-lg-4">
<div class="media">
<div class="d-none d-sm-block">
<img src="images/flappy-bird.png" class="rounded-circle mr-3" height=50 width=50>
</div>
<div class="media-body">
<h3>Flappy Bird</h3>
<h4>Python and Django</h4>
<p>A fun and interactive game where you are in control of a bird as you navigate through tight spaces.</p>
</div>
</div>
</div>
You are creating a new row for every item
Instead, put the col's in one row:
<div class="row">
<div class="col-4">
</div>
<div class="col-4">
</div>
<div class="col-4">
</div>
</div>
You don't need a new <div class="row"></div> around every <div class="col-lg-4"></div>. You can just wrap it around the entire lot to clear the floats.
<div class="row">
<div class="col-12 my-5">
<h2 class="text-uppercase">Portfolio</h2>
</div>
<div class="col-12 col-md-6 col-lg-4">
<div class="media">
<div class="d-none d-sm-block">
<img src="images/whiskey-drop.png" class="rounded-circle mr-3" height=50 width=50>
</div>
<div class="media-body">
<h3>Whiskey Drop</h3>
<h4>HTML, CSS, Bootstrap</h4>
<p>An e-commerce website for a premium whiskey service.</p>
</div>
</div>
</div>
<div class="col-12 col-md-6 col-lg-4">
<div class="media">
<div class="d-none d-sm-block">
<img src="images/rosie-odenkirk.png" class="rounded-circle mr-3" height=50 width=50>
</div>
<div class="media-body">
<h3>Resume</h3>
<h4>HTML, CSS, Bootstrap</h4>
<p>A responsive and user friendly resume showcasing a sample candidate in the best light possible.</p>
</div>
</div>
</div>
<div class="col-12 d-md-none d-lg-block col-lg-4">
<div class="media">
<div class="d-none d-sm-block">
<img src="images/flappy-bird.png" class="rounded-circle mr-3" height=50 width=50>
</div>
<div class="media-body">
<h3>Flappy Bird</h3>
<h4>Python and Django</h4>
<p>A fun and interactive game where you are in control of a bird as you navigate through tight spaces.</p>
</div>
</div>
</div>
</div>
Also make sure that you wrap your height and width values with "" too.
Is there a way to make each entire card selectable? I am only using html, materialize at the moment but the app is in angular too.
<div class="row">
<div class="col s12 m4">
<div class="card">
<div class="card-image">
<img src="./assets/SVSunset.jpg">
<span class="card-title">Agenda</span>
<a class="btn-floating halfway-fab waves-effect waves-light red"><i class="material-icons">add</i></a>
</div>
<div class="card-content">
<p>Whats happening when and where</p>
</div>
</div>
</div>
<div class="col s12 m4">
<div class="card">
<div class="card-image">
<img src="./assets/SVSunset.jpg">
<span class="card-title">Map</span>
</div>
<div class="card-content">
<p>Map with markers for church, reception etc</p>
</div>
</div>
</div>
<div class="col s12 m4">
<div class="card">
<div class="card-image">
<img src="./assets/SVSunset.jpg">
<span class="card-title">Confetti</span>
</div>
<div class="card-content">
<p>DIY some eco friendly confetti :)</p>
</div>
</div>
</div>
</div>
Any help would be great. Thanks
Ok, so this was easier than i thought by wrapping an <a href=""> around the cards div like below:
<div class="row">
<div class="col s12 m4">
<a href="https://stackoverflow.com">
<div class="card">
<div class="card-image">
<img src="./assets/SVSunset.jpg">
<span class="card-title">Agenda</span>
</div>
<div class="card-content">
<p>Whats happening when and where</p>
</div>
</div>
</a>
</div>
<div class="col s12 m4">
<a href="https://stackoverflow.com">
<div class="card">
<div class="card-image">
<img src="./assets/SVSunset.jpg">
<span class="card-title">Map</span>
</div>
<div class="card-content">
<p>Map with markers for church, reception etc</p>
</div>
</div>
</a>
</div>
<div class="col s12 m4">
<a href="https://stackoverflow.com">
<div class="card">
<div class="card-image">
<img src="./assets/SVSunset.jpg">
<span class="card-title">Confetti</span>
</div>
<div class="card-content">
<p>DIY some eco friendly confetti :)</p>
</div>
</div>
</a>
</div>
</div>
<div class="row">