How can I make divs inside of a column equal-height? - html

Problem: Divs not aligned:
The problem is when the text wraps, for example Money back guarantee, pushes the div out of alignment with 30 days.
I am trying to use the grid approach to first define two columns.
My code:
.inline-features {
display: grid;
grid-template-columns: repeat(2, 1fr);
}
<div class="inline-features">
<div class="feature">
<div class="price col-1-item">
<span>
Price
</span>
</div>
<div class="money-back col-1-item">
<span>
Money back guarantee
</span>
</div>
<div class="number-of-lessons col-1-item">
<span>
Number of lessons
</span>
</div>
<div class="number-of-users col-1-item">
<span>
Number of users
</span>
</div>
<div class="country col-1-item">
<span>
Based in country
</span>
</div>
<div class="support col-1-item">
<span>
Support
</span>
</div>
<div class="video-lessons col-1-item">
<span>
Video lessons
</span>
</div>
<div class="downloadable-files col-1-item">
<span>Downloadable files</span>
</div>
</div>
<div class="feature-item">
<div class="price-item col-2-item">
<span> From xx to xx </span>
</div>
<div class="money-back-item col-2-item">
<span> 30 days </span>
</div>
<div class="number-of-lessons-item col-2-item">
<span> 300+ </span>
</div>
<div class="number-of-users-item col-2-item">
<span> 35k + </span>
</div>
<div class="country-item col-2-item">
<span> UK</span>
</div>
<div class="support-item col-2-item">
<span> 24/7 live chat support </span>
</div>
<div class="video-lessons-item col-2-item">
<span> Yes </span>
</div>
<div class="downloadable-files-item col-2-item">
<span> Yes </span>
</div>
</div>
</div>

Your HTML structure is not correct. Try this way.
To do this type of design, you can use table. This will be better way for manage.
.inline-features{
width: 250px;
}
.row {
display: grid;
grid-template-columns: repeat(2, 1fr);
}
.col-1-item,
.col-2-item {
border: 1px solid black;
}
<div class="inline-features">
<div class="row">
<div class="col-1-item">
<span> Price </span>
</div>
<div class="col-2-item">
<span> From xx to xx </span>
</div>
</div>
<div class="row">
<div class="col-1-item">
<span> Money back guarantee </span>
</div>
<div class="col-2-item">
<span> 30 days </span>
</div>
</div>
<div class="row">
<div class="col-1-item">
<span> Number of lessons </span>
</div>
<div class="col-2-item">
<span> 300+ </span>
</div>
</div>
</div>

.inline-features {
display: grid;
grid-template-columns: repeat(2, 1fr);
font-size: 4rem;
border: 1px solid gray;
}
.col-1-item,
.col-2-item {
padding: 1rem;
height:140px;
border: 1px solid gray;
}
<div class="inline-features">
<div class="feature">
<div class="price col-1-item">
<span>Price</span>
</div>
<div class="money-back col-1-item">
<span>Money back guarantee</span>
</div>
<div class="number-of-lessons col-1-item">
<span>Number of lessons</span>
</div>
<div class="number-of-users col-1-item">
<span>Number of users</span>
</div>
<div class="country col-1-item">
<span>Based in country</span>
</div>
<div class="support col-1-item">
<span>Support</span>
</div>
<div class="video-lessons col-1-item">
<span>Video lessons</span>
</div>
<div class="downloadable-files col-1-item">
<span>Downloadable files</span>
</div>
</div>
<div class="feature-item">
<div class="price-item col-2-item">
<span>From xx to xx</span>
</div>
<div class="money-back-item col-2-item">
<span>30 days</span>
</div>
<div class="number-of-lessons-item col-2-item">
<span>300+</span>
</div>
<div class="number-of-users-item col-2-item">
<span>35k +</span>
</div>
<div class="country-item col-2-item">
<span>UK</span>
</div>
<div class="support-item col-2-item">
<span>24/7 live chat support </span>
</div>
<div class="video-lessons-item col-2-item">
<span>Yes</span>
</div>
<div class="downloadable-files-item col-2-item">
<span>Yes</span>
</div>
</div>
</div>

I suggest use instead of div and use CSS for border or other style
<table>
<tr>
<td>PRICE</td>
<td>From XX to XX</td>
</tr>
</table>

Related

how to display cards on the same line using display flex?

I need to display cards on the same line and use flex-wrap: wrap to wrap. But it's not working, what's wrong with my code?
Code
return(
<div className='container-poster'>
<div className='poster'>
<div className='poster-img'>
<img src={poster} />
<i>
{isFavorite ?
<FaHeart className='heart-icon' style={{ color: 'red' }} /> : <FaHeart className='heart-icon' style={{ color: '#BABABA' }} />
}
</i>
</div>
<div className='poster-title-vote'>
<h4 className='title-movie'>
{title}
</h4>
<div className='box-note'>
<span className='rating'>{rating}</span>
<i className='icon-vote-like'>
<img src={IconLike} alt="icon like"></img>
</i>
</div>
</div>
<p className='overview'>
{overview}
</p>
</div>
</div>
)
Reality
I want it to be a maximum of 4 cards in the same row and then break it when there's no space
SandBox
https://codesandbox.io/s/jolly-waterfall-10s5gx?file=/src/Poster.js
You'll want to add display: flex; on your parent .container-poster. This will make all elements nested in each flex-item .poster row item. You can then use display: flex; with flex-direction: column on your .poster to get the title underneath.
See below:
.container-poster {
display: flex;
justify-content: space-between;
}
.poster {
text-align: center;
display: flex;
flex-direction: column;
width: calc(100%/4.1); /* .1 for spacing */
}
img {
max-width: 100%;
}
<div class='container-poster'>
<div class='poster'>
<div class='poster-img'>
<img src="https://dummyimage.com/300/000/fff" />
</div>
<div class='poster-title-vote'>
<h4 class='title-movie'>Title
</h4>
</div>
<div class='box-note'>
<span class='rating'></span>
</div>
</div>
<div class='poster'>
<div class='poster-img'>
<img src="https://dummyimage.com/300/000/fff" />
</div>
<div class='poster-title-vote'>
<h4 class='title-movie'>Title
</h4>
</div>
<div class='box-note'>
<span class='rating'></span>
</div>
</div>
<div class='poster'>
<div class='poster-img'>
<img src="https://dummyimage.com/300/000/fff" />
</div>
<div class='poster-title-vote'>
<h4 class='title-movie'>Title
</h4>
</div>
<div class='box-note'>
<span class='rating'></span>
</div>
</div>
<div class='poster'>
<div class='poster-img'>
<img src="https://dummyimage.com/300/000/fff" />
</div>
<div class='poster-title-vote'>
<h4 class='title-movie'>Title
</h4>
</div>
<div class='box-note'>
<span class='rating'></span>
</div>
</div>
</div>

How to dynamically display cards in a grid

I am designing the UI for a web app which will dynamically display data from my database in form of cards and will be arranged in a grid. For testing purposes I have put two cards , one after the other , however, only the first one is being displayed.
How can I get them to be displayed in a 3 column row after which if there are more than 3, they overflow to the next row dynamically?
<div class="container_grid">
<div class="product-card" style="margin: 1rem">
<div class="product-front">
<div class="shadow"></div>
<img src="https://veenaazmanov.com/wp-content/uploads/2019/08/Chocolate-Birthday-Cake5-500x500.jpg" alt="" />
<div class="image_overlay"></div>
<div class="view-details">View details</div>
<div class="stats">
<div class="stats-container">
<span class="product_price">Ksh.500</span>
<span class="product_name">Chocolate Cake</span>
<p>Tasty cake</p>
<div class="product-options">
<strong>Available in</strong>
<span>1kg, 2kg, 3kg, 4kg, 5kg</span>
<button class="btn">Add To Cart</button>
<!-- <div class="cart_btn"><p>Add to Cart</p></div> -->
</div>
</div>
</div>
</div>
</div>
<div class="product-card" style="margin: 1rem">
<div class="product-front">
<div class="shadow"></div>
<img src="https://veenaazmanov.com/wp-content/uploads/2019/08/Chocolate-Birthday-Cake5-500x500.jpg" alt="" />
<div class="image_overlay"></div>
<div class="view-details">View details</div>
<div class="stats">
<div class="stats-container">
<span class="product_price">Ksh.500</span>
<span class="product_name">Chocolate Cake</span>
<p>Tasty cake</p>
<div class="product-options">
<strong>Available in</strong>
<span>1kg, 2kg, 3kg, 4kg, 5kg</span>
<button class="btn">Add To Cart</button>
</div>
</div>
</div>
</div>
</div>
</div>
Link to the full JFiddle: https://jsfiddle.net/5yoerguh/3/
What am I doing wrong?
Both are being displayed if you check the console both div class='product-card' is there.
The problem is in the css your class .propduct-card is displayed with position:absolute;
.product-card {
width: 20rem;
max-width: 95%;
width: 325px;
height: 490px;
--> take this out /* position: absolute; */
overflow: hidden;
}
Now you will see both items

How can I make my container to go down automatically of the page

How can I make my container to go down automatically of the page if it exceed the width of the page? The page background is in black if you look at the jsfiddle and it's size is 780px. All two credit cards are displaying over the page. Thanks.
My CSS as below:
<div style="width:780px;background:#000">
<div class="container">
<div class="sleeve">
<div class="credit-card">
<div class="card-company">West Frodo</div>
<div class="card-number">
<div class="digit-group">4141 7204 9012 0029</div>
</div>
<div class="card-expire"><span class="card-text">CVC</span> 321 <span class="card-text">Expires</span> 12/24</div>
<div class="card-holder">John P. Smith</div>
<div class="card-type">Debit card</div>
</div>
</div>
<div class="sleeve">
<div class="credit-card selected" style="background: #555">
<div class="card-company">West Frodo</div>
<div class="card-number">
<div class="digit-group">4234 1302 3798 0265</div>
</div>
<div class="card-expire"><span class="card-text">CVC</span> 321 <span class="card-text">Expires</span> 12/24</div>
<div class="card-holder">John P. Smith</div>
<div class="card-type">Debit card</div>
</div>
</div>
<div class="sleeve">
<div class="credit-card" style="background: #3B3">
<div class="card-company">West Frodo</div>
<div class="card-number">
<div class="digit-group">4812 0322 0517 2840</div>
</div>
<div class="card-expire"><span class="card-text">CVC</span> 321 <span class="card-text">Expires</span> 12/24</div>
<div class="card-holder">John P. Smith</div>
<div class="card-type">Debit card</div>
</div>
</div>
<div class="sleeve">
<div class="credit-card" style="background: #3B3">
<div class="card-company">West Frodo</div>
<div class="card-number">
<div class="digit-group">4812 0322 0517 2840</div>
</div>
<div class="card-expire"><span class="card-text">CVC</span> 321 <span class="card-text">Expires</span> 12/24</div>
<div class="card-holder">John P. Smith</div>
<div class="card-type">Debit card</div>
</div>
</div>
</div>
</div>
Here's my fiddle: http://jsfiddle.net/5gronvk1/1/
Update the following selectors in your CSS with the following:
.container {
height: 100%;
}
and
.sleeve {
display: inline-block;
margin: auto;
}

Align text to the right side of a button radio

I have a theme which have this section below , I want to align the text on the right side of a radio button, right now it below the radio button
Here is what I want:
Here is jsfiddle: http://jsfiddle.net/Mwanitete/Jm2JR/181/
<div class="delivery_options">
<div class="delivery_option item" style="margin: 0px;padding: 0px;">
<div>
<label class="delivery-option-label" for="delivery_option_13687_0">
<div class="resume div div-bordered">
<div>
<div class="delivery_option_radio">
<input id="delivery_option_13687_0" class="delivery_option_radio" type="radio" name="delivery_option[13687]" data-key="233," data-id_address="13687" value="233,">
</div>
<div class="delivery_option_logo">
</div>
<div>
Kurier DHL (2-5dni roboczych)
<span class="delivery_option_price">
12,00 zł
</span>
<br>
<span class="best_grade best_grade_speed">The fastest</span>
</div>
</div>
</div>
</label>
</div>
</div>
<!-- end delivery_option -->
<div class="delivery_option alternate_item" style="margin: 0px; padding: 0px; float: none;">
<div>
<label class="delivery-option-label" for="delivery_option_13687_1">
<div class="resume div div-bordered">
<div>
<div class="delivery_option_radio">
<input id="delivery_option_13687_1" class="delivery_option_radio" type="radio" name="delivery_option[13687]" data-key="234," data-id_address="13687" value="234,">
</div>
<div class="delivery_option_logo">
</div>
<div>
Kurier DHL - pobranie (2-5 dni roboczych)
<span class="delivery_option_price">
12,00 zł
</span>
<br>
</div>
</div>
</div>
</label>
</div>
</div>
<!-- end delivery_option -->
<div class="delivery_option item" style="margin: 0px; padding: 0px; float: none;">
<div>
<label class="delivery-option-label" for="delivery_option_13687_2">
<div class="resume div div-bordered">
<div>
<div class="delivery_option_radio">
<input id="delivery_option_13687_2" class="delivery_option_radio" type="radio" name="delivery_option[13687]" data-key="235," data-id_address="13687" value="235,">
</div>
<div class="delivery_option_logo">
</div>
<div>
Odbiór osobisty - Showroom - Mokotowska 40/3, Warszawa (2-3 dni roboczych)
<span class="delivery_option_price">
Free
</span>
<br>
<span class="best_grade best_grade_price">The best price</span>
</div>
</div>
</div>
</label>
</div>
</div>
<!-- end delivery_option -->
<div class="delivery_option alternate_item" style="margin: 0px; padding: 0px; float: none;">
<div>
<label class="delivery-option-label" for="delivery_option_13687_3">
<div class="resume div div-bordered">
<div>
<div class="delivery_option_radio">
<input id="delivery_option_13687_3" class="delivery_option_radio" type="radio" name="delivery_option[13687]" data-key="231," data-id_address="13687" value="231," checked="checked">
</div>
<div class="delivery_option_logo">
</div>
<div>
Odbiór osobisty - Sklep - Stary Browar, Poznań (2-5 dni roboczych)
<span class="delivery_option_price">
Free
</span>
<br>
</div>
</div>
</div>
</label>
</div>
</div>
<!-- end delivery_option -->
</div>
I tried using float but didnt work, any idea or help, suggestion will be apreciated, please help
add this line to your css
.resume > div {
display: flex;
}

How do i align all these Read Mores in the same line in bootstrap

I'm making a menu but my "Read More"s are not aligned on the same line
https://i.gyazo.com/3a9dd4d8e497b3772110edd4ac35fa76.png
Here's the HTML code for it
<div class="home-menu parallax" data-stellar-background-ratio="0.5">
<div class="container no-padding">
<div class="hm-info">
<div class="row">
<div class="col-md-4">
<h3><span>Today Deals</span>Breakfast</h3>
<h4>Pancakes with Seasonal Fruit</h4>
<div class="menu-wrapper">
<p>Maple Syrup & Icecream</p>
<span class="price">$13.95</span>
<div class="dotted-bg"></div>
</div>
<h4>Pancakes with Maple Syrup</h4>
<div class="menu-wrapper">
<p>And Bacon</p>
<span class="price">$15.95</span>
<div class="dotted-bg"></div>
</div>
<h4>Smoked Salmon Omelette</h4>
<div class="menu-wrapper">
<p>with Onion, Capers and Toast</p>
<span class="price">$16.95</span>
<div class="dotted-bg"></div>
</div>
<h4>French Toast</h4>
<div class="menu-wrapper">
<p>with Maple Syrup</p>
<span class="price">$15.95</span>
<div class="dotted-bg"></div>
</div>
<div class="menureadmore">
Read More
</div>
</div>
<div class="col-md-4">
<h3><span>Today Deals</span>Coffee</h3>
<div class="menu-wrapper">
<span class="price">$12.00</span>
<h4>Cappucino</h4>
</div>
<div class="menu-wrapper">
<span class="price">$3.95</span>
<h4>Flat White</h4>
</div>
<div class="menu-wrapper">
<span class="price">$4.20</span>
<h4>Latte</h4>
</div>
<div class="menu-wrapper">
<span class="price">$4.80</span>
<h4>Chai Latte</h4>
</div>
<div class="menu-wrapper">
<span class="price">$4.40</span>
<h4>Hot Chocolate</h4>
</div>
<div class="menu-wrapper">
<span class="price">$4.55</span>
<h4>Hot Mocha</h4>
</div>
<div class="menureadmore" >
Read More
</div>
</div>
<div class="col-md-4">
<h3><span>Today Deals</span>Lunch</h3>
<h4>Beef Lasagne</h4>
<div class="menu-wrapper">
<p>With Salad</p>
<span class="price">$16.95</span>
<div class="dotted-bg"></div>
</div>
<h4>Fabulous Thai Chicken Patties</h4>
<div class="menu-wrapper">
<p>with Salad (Gluten Free)</p>
<span class="price">$15.95</span>
<div class="dotted-bg"></div>
</div>
<h4>Sensational Fillet Steak</h4>
<div class="menu-wrapper">
<p>Salad & Chips.</p>
<span class="price">$21.95</span>
<div class="dotted-bg"></div>
</div>
<h4>Roasted Vegetable Rosti Stack</h4>
<div class="menu-wrapper">
<p>(Gluten Free) with Salad</p>
<span class="price">$16.95</span>
<div class="dotted-bg"></div>
</div>
<div class="menureadmore">
Read More
</div>
</div>
</div>
</div>
</div>
</div>
And CSS
.menu-wrapper .price
{
float: right;
padding-left: 10px;
line-height: 19.8px;
margin: 5px 0px;
background: #f7f3e8;
font-weight: 700;
font-size: 15px;
color: #d80702;
font-family: Lato;
position: relative;
z-index: 11;
}
.menureadmore{
text-align:center;
font-weight:700;
font-size: 16px;
}
How do i align those "Read More"s so they are all aligned vertically?
Thanks
Bootstrap grid system is for row layouts and so the row that contains read more , that row should be enclosed in a div with class of row and then you can give them cols and they will align perfectly
give position fix with bottom 0 or whatever you want (can also try with potion absolute)