How to set the buttons for all cards at the bottom? - html

how do I align all buttons at the bottom of the card? The body of the card is already on display:flex and flex-direction: column, while the card buttons' margin-top are already set at 'auto' however the it's still not being positioned at the bottom?
I attached below the code structure for my cards including the styling for the card content and the buttons.
[![enter image description here](https://i.stack.imgur.com/eJLHT.png)](https://i.stack.imgur.com/eJLHT.png)
<section class="container">
<div class="card">
<div class="card-img card-1"></div>
<div class="card-content">
<h2 class="card-header">Bayanihan E-Konsulta</h2>
<p class="card-text">The Bayanihan e-Konsulta – a teleconsultation program aimed at assisting both COVID-19 and non-COVID-19 patients which was initially launched to fill the gaps in the government’s pandemic response.</p>
<button class="card-btn">Read more<span>→</span></button>
</div>
</div>
<div class="card">
<div class="card-img card-2"></div>
<div class="card-content">
<h2 class="card-header">Swab Cab</h2>
<p class="card-text">A mobile testing program which will do mass surveillance testing in communities where transmission is very high.</p>
<button class="card-btn card-btn-2">Read more<span>→</span></button>
</div>
</div>
<div class="card">
<div class="card-img card-3"></div>
<div class="card-content">
<h2 class="card-header">Free PPEs for HCWs</h2>
<p class="card-text">Vice President Leni Robredo’s office continues its livelihood assistance projects as it turned over materials to a group of Bulacan sewers, who were tapped to make personal protective equipment (PPEs) who were tapped to make personal protective equipment (PPEs). </p>
<button class="card-btn">Read more<span>→</span></button>
</div>
</div>
BACK TO TOP
</section>
`
The body of the card is already on display:flex and flex-direction: column, while the card buttons' margin-top are already set at 'auto'. I can fix this by manually adjusting the button's margin but I think it's possible to adjust all buttons simultaneously.

I prepared a example in codepen:
https://codepen.io/isaksonn/pen/eYKzarW
section.container .card{display:flex;flex-direction:column;justify-content:space-between;height:600px;width:200px;border:1px solid gray;padding:10px}section.container .card .card-img{display:block;background-color:gray;width:100%;height:200px}section.container .card .card-content{height:100%;display:flex;flex-direction:column;justify-content:space-between}
<section class="container">
<div class="card">
<div class="card-img card-1"></div>
<div class="card-content">
<!--If you want align the title and text on the top and only the buttons down you have to wrap the firsts in a div, otherwise the text is centered vertically (as second card)-->
<div class="divAdded">
<h2 class="card-header">Bayanihan E-Konsulta</h2>
<p class="card-text">The Bayanihan e-Konsulta – a teleconsultation program aimed at assisting both COVID-19 and non-COVID-19 patients which was initially launched to fill the gaps in the government’s pandemic response.</p>
</div>
<button class="card-btn">Read more<span>→</span></button>
</div>
</div>
<div class="card">
<div class="card-img card-2"></div>
<div class="card-content">
<h2 class="card-header">Swab Cab</h2>
<p class="card-text">A mobile testing program which will do mass surveillance testing in communities where transmission is very high.</p>
<button class="card-btn card-btn-2">Read more<span>→</span></button>
</div>
</div>
BACK TO TOP
</section>

section.container .card{height:600px;width:200px;border:1px solid gray;padding:10px}
section.container .card .card-img{display:block;background-color:gray;width:100%;height:200px}
.btn{
text-align: center;
margin: 10px 0;
}
<section class="container">
<div class="card">
<div class="card-img card-1"></div>
<div class="card-content">
<!--If you want align the title and text on the top and only the buttons down you have to wrap the firsts in a div, otherwise the text is centered vertically (as second card)-->
<div class="divAdded">
<h2 class="card-header">Bayanihan E-Konsulta</h2>
<p class="card-text">The Bayanihan e-Konsulta – a teleconsultation program aimed at assisting both COVID-19 and non-COVID-19 patients which was initially launched to fill the gaps in the government’s pandemic response.</p>
</div>
<p class="btn"><button class="card-btn">Read more<span>→</span></button></p>
</div>
</div>
<div class="card">
<div class="card-img card-2"></div>
<div class="card-content">
<h2 class="card-header">Swab Cab</h2>
<p class="card-text">A mobile testing program which will do mass surveillance testing in communities where transmission is very high.</p>
<p class="btn"><button class="card-btn card-btn-2">Read more<span>→</span></button></p>
</div>
</div>
BACK TO TOP
</section>
You can try this..
add button element in 'p' and you can add class in 'p' element and than go to css file and style

Related

How to vertically align text in html/css? [duplicate]

This question already has answers here:
How to vertically align text inside a flexbox?
(13 answers)
Closed 4 years ago.
I am working on a fiddle in which I want to vertically align James text in html/css as shown below in the image. The HTML code which I have used for that is:
<div class="tab-pane" id="reviews" style="display: block;">
<p>
<span class="heading_size">reviews:</span>
</p>
<p class="text-justify mb-0 mb-1">
</p>
<div class="review">
<div class="mb-2 renter_review">
<div class="renter_rating_image">
<img class="item_review_image" src="https://i.imgur.com/lbDo4tM.jpg">
</div>
<p style="text-align:center;font-style:italic;margin-bottom:0%;">this bobcat was amazing</p>
<span>10.22,07, 04, 18</span>
</div>
<div class="renter_review_firstname">James</div>
</div>
<div class="review">
<div class="mb-2 renter_review">
<div class="renter_rating_image">
<img class="item_review_image" src="https://i.imgur.com/lbDo4tM.jpg">
</div>
<p style="text-align:center;font-style:italic;margin-bottom:0%;">it was perfect!</p>
<span>10.14,01, 17, 18</span>
</div>
<div class="renter_review_firstname">James</div>
</div>
<p></p>
</div>
In the fiddle, the text James is not properly aligned. I am wondering what changes I need to do in the HTML/CSS code so that the text James is aligned vertically properly.
I have a feeling width of this bobcat was amazing and it was perfect text is making James text not properly aligned vertically.
Problem Statement:
I am wondering what changes I need to do HTML/CSS code so that James text is properly vertically aligned.
At this moment, as shown in the image below, the upper James text is quite right in comparison to the lower James text.
You can use this solution, or another now we have a GRID also.
This solution, is to wrapping the content of your container with review class, and use flexbox for what you want.
.wrapper-review {
display: flex;
flex-flow: row wrap;
}
<div class="tab-pane" id="reviews" style="display: block;">
<p>
<span class="heading_size">reviews:</span>
</p>
<p class="text-justify mb-0 mb-1">
</p>
<div class="wrapper-review">
<div class="review">
<div class="mb-2 renter_review">
<div class="renter_rating_image">
<img class="item_review_image" src="https://i.imgur.com/lbDo4tM.jpg">
</div>
<p style="text-align:center;font-style:italic;margin-bottom:0%;">this bobcat was amazing</p>
<span>10.22,07, 04, 18</span>
</div>
<div class="renter_review_firstname">James</div>
</div>
<div class="review">
<div class="mb-2 renter_review">
<div class="renter_rating_image">
<img class="item_review_image" src="https://i.imgur.com/lbDo4tM.jpg">
</div>
<p style="text-align:center;font-style:italic;margin-bottom:0%;">it was perfect!</p>
<span>10.14,01, 17, 18</span>
</div>
<div class="renter_review_firstname">James</div>
</div>
</div>
<p></p>
</div>
Trying adding the following to your css
p {
width: min-content;
}
But you should try using a grid system like http://getbootstrap.com. It helps a ton! :)

How to vertically stack bootstrap elements

I've got a header, paragraph and image, and I want them aligned with the header above the paragraph, and the image to the right. When I run it I get the 3 elements in a horizontal row
<div class="container">
<div class="row">
<h1 class="col-xs-3 paddingtop">Joselin</h1>
<p class="col-xs-3 bio">
Growing up in the Caribbean, as a young girl Joselin worked as a
coffee bean picker, giving her a profound insight into using only
the freshest, and highest quality coffee beans.
</p>
<img class="col-xs-6 meetus" src="meetus.jpeg">
</div>
</div>
If the h1 should be above the p and the img, the best thing would be to put it in its own row: <div class="row">. Then put the p and the img in a row right under that.
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container">
<div class="row">
<div class="col-xs-6">
<h1 class="paddingtop">Joselin</h1>
<p class="bio">
Growing up in the Caribbean, as a young girl Joselin worked as a
coffee bean picker, giving her a profound insight into using only
the freshest, and highest quality coffee beans.
</p>
</div>
<div class="col-xs-6">
<img class="col-xs-6 meetus" src="meetus.jpeg">
</div>
</div>
</div>
You can then play around with the column sizes (`class="col-xs-3").

How can I get a w3-cell to not auto adjust?

Working on a HTML page that requires me to have two elements side by side to replicate a 50/50 scenario sort of thing. I am using w3.css to help me since I am not so familiar with HTML/CSS.
My code is below for the section. So when the AWords/BWords grows too big, the cell grows so it does not match the other half. What I'm trying to ask is how can I implement a uniformly increase in size? So that both halves match each other, and the halfway mark stays in the middle of the screen?
<div class="Options w3-cell-row w3-center" style="width:75%;margin: 0 auto;">
<div class="OptionA w3-container w3-cell" style="background-color: #EA4D63;border-style: solid;border-top-left-radius:25px;border-bottom-left-radius: 25px;">
<div class="w3-container">
<p class="AWords w3-xxlarge"></p>
</div>
<div class="w3-container">
<p class="AVotes w3-large"></p>
</div>
</div>
<div class="OptionB w3-container w3-cell" style="background-color:#2BA9E5;border-style: solid;border-top-right-radius: 25px;border-bottom-right-radius: 25px;">
<div class="w3-container">
<p class="BWords w3-xxlarge"></p>
</div>
<div class="w3-container">
<p class="BVotes w3-large"></p>
</div>
</div>
</div>
JSFiddle of what the code currently does
Assuming by the 'halfway' mark you mean the line that divides the two elements vertically, this arises due to the fact that W3 uses a table-based layout. Tables automatically expand to contain their contents.
As such, in order to ensure that both elements occupy the same amount of horizontal space, you simply give your cells a fixed width. This can be done by targeting .w3-cell:
.w3-cell {
width: 200px;
}
And can be seen in the following:
.w3-cell {
width: 200px;
}
<link href="https://www.w3schools.com/w3css/4/w3.css" rel="stylesheet"/>
<div class="Options w3-cell-row w3-center" style="width:75%;margin: 0 auto;">
<div class="OptionA w3-container w3-cell" style="background-color: #EA4D63;border-style: solid;border-top-left-radius:25px;border-bottom-left-radius: 25px;">
<div class="w3-container">
<p class="AWords w3-xxlarge">Idk what to do</p>
</div>
<div class="w3-container">
<p class="AVotes w3-large"></p>
</div>
</div>
<div class="OptionB w3-container w3-cell" style="background-color:#2BA9E5;border-style: solid;border-top-right-radius: 25px;border-bottom-right-radius: 25px;">
<div class="w3-container">
<p class="BWords w3-xxlarge">If this side gets too big it looks weird</p>
</div>
<div class="w3-container">
<p class="BVotes w3-large"></p>
</div>
</div>
</div>
I've also created a Fiddle showcasing this here.
Note that if you want to continue to use inline styles everywhere, you'll have to apply this to both <div> elements with this class.
Hope this helps :)

Suggestions to fix columns in Bootstrap?

How can I make 3 columns be dead centered?
They are spread out currently.
<div class="container container2">
<div class="row no-gutter">
<div class="col-md-4">
<h1>1</h1>
<p class="description1">elige<br>tu box</p>
<img class="crop-img" src="img/icono_elige.jpg" alt="delivery" />
<p class="description">elije entre la</br><b>box mensual</b> o la <b> </br> box personalizada</b></p>
</div>
<div class="col-md-4">
<h1>2</h1>
<p class="description1">elige<br>tus snacks</p>
<img class="crop-img" src="img/icono_snacks.jpg" alt="elige" />
<p class="description">encuentra mas de<br> <b>80 snacks</b> y<br>agregalos a tu box</p>
</div>
<div class="col-md-4">
<h1>3</h1>
<p class="description1">pide y<br>recibe</p>
<img class="crop-img" src="img/icono_delivery.png" alt=elige />
<p class="description">para ti, para<br> compartir o para<br>regalar</p>
</div>
</div>
http://imgur.com/a/UjOlV
Top - What I have
Bottom - What I need
Thanks for your help :)
All three boxes have the same width (some where around 33.3333%). I think you're using text-align: center; which will place the contents in the middle of the boxes. I think the best solution is making the middle box smaller.
You can also use col-push and col-pull.
To find more information about this, check http://getbootstrap.com/css/#grid-offsetting.
Just try using different sizes of columns and offsetting these.

Test doesn't stack when screen is minimized bootstrap 3

Ok so I have the following HTML
<div class="container">
<div class="row col-sm-12" id="productBrief">
<div id="RaspberryAndChocolate" style="display:none; height:200px;">
<div class="col-sm-6 text-center">
<img src="~/Content/Images/YogurtImages_404x290/Rasberry_White_Chocolate_Yogurt.png" class="img-responsive" style="margin: 0 auto; padding-top: 5%" alt="Rasberry White Chocolate Yogurt" />
</div>
<div class="col-sm-6">
<h2 class="raspberryRed productLineHeight">FLAVOUR #3</h2>
<h1 class="raspberryRed">
RASPBERRY &<br /> WHITE CHOCOLATE
</h1>
<p class="productPara">
A decadent combination of whole raspberries and smooth white chocolate that you will want to make last as long as possible. Teaspoon recommended.
</p>
<p>
<span class="label label-danone label-as-badge" style="font-size: 0.9em; padding:3%">VIEW ALL FLAVOURS</span>
</p>
</div>
</div>
<div class="clearfix"></div>
<div id="BlueBerry" style="display:none; height:200px;">
<div class="col-sm-6 text-center">
<img src="~/Content/Images/YogurtImages_404x290/Blueberry_Yogurt.png" class="img-responsive" style="margin: 0 auto; padding-top: 5%" alt="Blueberry Yogurt" />
</div>
<div class="col-sm-6">
<h2 class="blueBerry productLineHeight">FLAVOUR #6</h2>
<h1 class="blueBerry">
BLUEBERRY
</h1>
<p class="productPara">
Just imagine plump and juicy blueberries immersed in a deliciously creamy yoghurt. Enough said.
</p>
<p>
<span class="label label-as-badge" style="font-size: 0.9em; padding:3%">VIEW ALL FLAVOURS</span>
</p>
</div>
</div>
<div class="clearfix"></div>
</div>
<div class="clearfix"></div>
<div class="row">
<div class="col-lg-12 text-center">
<div class="col-lg-2"></div>
<p style="width:70%;" class="text-center col-lg-8">
Experiencing Ultimate's uniquely luscious texture for the first time is beyond words. So don't even try. Take a moment to enjoy the ultra creaminess, the juicy ripened fruits and an array of wicked indulgences that come together to create a yoghurt like no other.
</p>
<div class="col-lg-2"></div>
</div>
</div>
Now there are roughly about 8 different divs but for simplicity I am only showing 2, but only one div is shown look at it as a random affect so the user refreshes the page a different div is shown (this is done in jquery) but if you look at the bottom of the HTML you will see another row with a P tag this is what is causing he issue, when displayed on a desktop it shows like this
when I minimize the browser the text at the bottom of the image displays under the text located to the right hand side of the yogurt box as shown here.
I have added the clearfix, tried adding a new container and yet the problem still remains....
You are using invalid bootstrap grid. Col should be a child of row. Use correct grid and everything will work perfectly.
Scott, hunzaboy says you need to use the dive like this
<div class="row">
<div class="col-sm-12"></div>
</div>
I don't fully understand your question, but hope you asking this,
when re-sizing your first image, I will suitably re-size without any harm to other divs. For that You need to devide that into 3 main divs, check the below code
<div class="row">
<div class="col-md-6">This is the image holding div</div><div class="col-md-6"> this is the right side text "Flavour #6, etc..."</div>
<div class="col-md-12">This is the text on the bottom</div>
</div>
I will look, 2 columns on the top and one column in the bottom.
For mobile view, you can use col-xs-12class, the it will show as stack.
Hope this is you asking. Thanks