height adjust of the content based on additional length of data - html

I have list of tools in a 2x2 grid layout, the problem here is sometimes the tool image and tool name have either more height based on there image and name. So i have read that we should not keep the image width and height. What i want to achieve is that if the second column has more content it should align exactly same. So that my Add to Cart will align exactly same
.tools-list-container {
display: grid;
grid-gap: 16px;
grid-template-columns: repeat(auto-fill, minmax(min(136px, 100%), 1fr));
}
.tool-card-container {
background: #ffffff;
border: 1px solid #e1e4e7;
box-sizing: border-box;
border-radius: 8px;
padding: 12px;
}
.tool-image-container img {
width: 100%;
object-fit: cover;
height: 80px; // to adjust the height
}
.tool-name {
font-weight: 600;
font-size: 14px;
line-height: 20px;
margin-top: 20px;
}
.tool-description{
font-style: normal;
font-weight: 400;
font-size: 12px;
line-height: 20px;
margin-top: 2px;
}
.tool-amount-action-container {
display: flex;
justify-content: space-between;
align-items: center;
margin-top: 6px;
}
.tool-our-price {
font-weight: 600;
font-size: 19px;
line-height: 20px;
}
.tool-mrp {
font-style: normal;
font-weight: 400;
font-size: 13px;
line-height: 20px;
}
.button-wrapper {
border-radius: 4px;
display: flex;
align-items: center;
justify-content: center;
background: grey;
border: 1px solid grey;
cursor: pointer;
}
<div class="tools-list-container">
<div class="tool-card-container">
<div class="tool-image-container"><img src="https://picsum.photos/id/237/200/300" alt="Tool one"></div>
<div class="tool-name">Test Tool 1</div>
<div class="tool-description">1.25 kg of weight</div>
<div class="tool-amount-action-container">
<div class="tool-amount-container"><span class="tool-our-price">₹9</span><span class="tool-mrp">10</span></div>
<div class="action-container">
<div class="button-wrapper" style="padding: 7px 11px; font-size: 15px;">
<div class="button-text">Add to cart</div>
</div>
</div>
</div>
</div>
<div class="tool-card-container">
<div class="tool-image-container"><img src="https://picsum.photos/id/237/200/400" alt="Tool two"></div>
<div class="tool-name">Test Tool more detail name 2</div>
<div class="tool-description">1 kg of weight</div>
<div class="tool-amount-action-container">
<div class="tool-amount-container"><span class="tool-our-price">₹9</span><span class="tool-mrp">10</span></div>
<div class="action-container">
<div class="button-wrapper" style="padding: 7px 11px; font-size: 15px;">
<div class="button-text">Add to cart</div>
</div>
</div>
</div>
</div>
</div>
If i add below snippet then i will be able to control the height of the image
.tool-image-container img {
width: 100%;
object-fit: cover;
height: 80px;
}
but i don't know inside a grid how can i control the text height so if tool name is more than also it the content of two column align exactly same. so that the Add to cart will be same across every row
Any help is appreciated

Related

How to display container that is centered with content that is in the far left and far right of it

I would like to display the price of an object on my html website. This is what I would like it to look like:
Dynamic
The container is centered on the page with a max width of 400px
The "price" string is on the far left while the actual price is on the right of the centered content
This is what my html looks like:
<div class="price-container">
<div class="price">price:</div>
<div class="price-number">{{ event.price }}.00</div>
</div>
This is what my css looks like:
.price-container{
font-family: Montserrat;
text-transform: uppercase;
color: white;
font-weight: 700;
font-size: 20px;
width: 90%;
max-width: 400px;
}
.price{
float: left;
}
.price-number{
float: right;
}
If you want to center it horizontally, you need to add margin:auto. I also cleared the floats for you.
.price-container{
font-family: Montserrat;
text-transform: uppercase;
color: black;
font-weight: 700;
font-size: 20px;
width: 90%;
max-width: 400px;
margin: auto;
border: 1px solid red;
}
.price{
float: left;
}
.price-number{
float: right;
}
<div class="price-container">
<div class="price">price:</div>
<div class="price-number">{{ event.price }}.00</div>
<div style="clear:both"></div>
</div>
We can also write like this:
<div class="price-container">
<div class="price">price:</div>
<div class="price-number">{{ event.price }}.00</div>
</div>
CSS:
.price-container{
font-family: Montserrat;
text-transform: uppercase;
color: black;
font-weight: 700;
font-size: 20px;
width: 90%;
margin: 0 auto;
max-width: 400px;
border: 1px solid red;
display: flex;
justify-content: space-between;
}

Position of text in mobile version of web page

I have a slider, and text inside it, and I need to make this text responsive. I mean in computer version it looks like as I want, but in mobile version it shifts and I can`t see my icons under each other.
css:
.sliderr__item .slid{
display: flex;
flex-direction: column;
width: 100%;
margin-left: 50px;
margin-top: 50px;
text-align: left;
align-items: flex-start;
justify-content: flex-start;
}
/*END*/
.sliderr {
background-color: #fff;
position: relative;
overflow: hidden;
width: 100%;
}
.sliderr__wrapper {
display: flex;
transition: transform 0.6s ease;
/* ADDED: */
margin-bottom: 10px;
}
.sliderr__item {
flex: 0 0 50%;
}
.sliderr .date {
display: inline-block;
margin-left: 1em;
}
/* Added: */
.sliderr__controls {
display: flex;
justify-content: center;
flex-flow: row;
}
.sliderr__control {
/* Added: */
border-radius: 50%;
/* Updated: */
position: relative;
top: 0;
width: 25px;
/* The Same: */
display: flex;
align-items: center;
justify-content: center;
color: #fff;
text-align: center;
height: 25px;
background: #5FA467;
/*
REMOVED: transform: translateY(-50%);
*/
}
html:
<div class="sliderr"><br>
<div class="sliderr__wrapper">
<div class="sliderr__item" style="border: 1px solid #DCE2EC;">
<div style="height: 150px;" class="slid">
<p style="font-family: Roboto; font-size: 14px; color: #5FA467;">My first text</p><br>
<p style="font-family: Roboto; font-size: 16px; color: #000; font-weight: bold;">My second text</p><br>
<p style="display: inline-block; font-family: Roboto; font-size: 14px; color: #000;"><img src="https://via.placeholder.com/20" style="width: 18px; height: 18px;"><span>My User</span><img src="https://via.placeholder.com/20" style="margin-left: 20px;"> 21.08.2018</p>
</div>
</div>
<div class="sliderr__item" style="border: 1px solid #DCE2EC;">
<div style="height: 150px;" class="slid">
<p style="font-family: Roboto; font-size: 14px; color: #5FA467;">My first text</p><br>
<p style="font-family: Roboto; font-size: 16px; color: #000; font-weight: bold;">My second text</p><br>
<p style="display: inline-block; font-family: Roboto; font-size: 14px; color: #000;"><img src="https://via.placeholder.com/20" style="width: 18px; height: 18px;"><span>My User</span><img src="https://via.placeholder.com/20" style="margin-left: 20px;"> 21.08.2018</p>
</div>
</div>
</div>
</div>
So, I have 3 paragraph of text and in mobile version I need to see them in the center and under each other and icons need to be under each others with their text. How can I make that? Full sample in this JSFiddle https://jsfiddle.net/ofzpnL2k/4/
You can use CSS media queries to achieve different stylink for mobile. It's like if conditionals for CSS.
Here you can find more explanation about it: https://www.w3schools.com/csSref/css3_pr_mediaquery.asp.

Force the height in css

I have a problem, in fact I have a block named "e-mail" which descend, I will want to force the height, is it possible?
Do you have an idea of the process to follow?
I don't know if my pratice html/css is good also?
Thank you for your answer.
.logo5{
padding-top: 35px;
padding-left: 80px;
}
.title-contact-1{
font-family: 'Questrial', sans-serif;
font-size: 22px;
margin-top: -32px;
padding-left: 100px;
position: absolute;
}
.text-contact-1{
padding-left: 80px;
}
.line-verticale{
margin-top: -60px;
margin-left: 250px;
border-left:1px solid #e0e0e0;
height:100px;
}
.logo6{
padding-top: 35px;
padding-left: 80px;
}
.title-contact-2{
font-family: 'Questrial', sans-serif;
font-size: 22px;
margin-top: -32px;
padding-left: 120px;
position: absolute;
}
.text-contact-2{
padding-left: 80px;
}
<div class="background-contact">
<img class="logo5" src="https://i.ibb.co/0YyTszS/title-icon1.png">
<div class="title-contact-1">Telephone</div>
<div class="text-contact-1">Just For VIP Member</div>
<div class="line-verticale" ></div>
<img class="logo6" src="https://i.ibb.co/026Fs1B/title-icon2.png">
<div class="title-contact-2">E-mail</div>
<div class="text-contact-2">admin#superbtc.biz</div>
<div class="line-verticale" ></div>
</div>
I think the email descends because of the image size. Have you tried setting image size? The telephone image and email is of different size. For example,
img {
max-width: 10px;
}
I had to restructure, but now you can adjust images and the content easily
.contact-info {
font-family: 'Questrial', sans-serif;
}
.contact-item {
border-right: 1px solid #e0e0e0;
padding: 20px;
max-width: 200px;
margin-bottom: 20px;
text-align: center;
}
.contact-item__logo {
vertical-align: middle;
}
.contact-item__title {
font-size: 22px;
vertical-align: middle;
}
.contact-item--email .contact-item__title {
padding-top: 10px
}
.contact-item__text {
margin-top: 10px;
}
<div class="contact-info background-contact">
<div class="contact-item contact-item--phone">
<div class="contact-item__header">
<img class="contact-item__logo" src="https://i.ibb.co/0YyTszS/title-icon1.png">
<span class="contact-item__title">Telephone</span>
</div>
<div class="contact-item__text">Just For VIP Member</div>
</div>
<div class="contact-item contact-item--email">
<div class="contact-item__header">
<img class="contact-item__logo" src="https://i.ibb.co/026Fs1B/title-icon2.png">
<span class="contact-item__title">E-mail</span>
</div>
<div class="contact-item__text">admin#superbtc.biz</div>
</div>
</div>

3 row div or table with different style for each row ( text and image)

I have been stuck on this for about a day and can't seem to figure out the best way to handle this.
I am trying to put 3 elements inline inside of a dive on multiple rows.
a bold heading, a regular text element and a small icon, that need to have spacing between each and stacked 5 times.
Here is my code, it's scaling differently in jfiddle than on my html document. but i believe the general idea is clear.
In my mind I want to add padding to each element but I'm not sure how to pull this off.
I have included annotations for each class in my css
/* Typography */
h5 {
font-family: 'proxima_nova_rgbold', sans-serif;
font-size: 16px;
line-height: 20px;
font-weight: bold;
padding: 40px 0 20px 40px;
}
h3 {
font-family: 'proxima_nova_rgbold', sans-serif;
font-size: 16px;
line-height: 20px;
font-weight: bold;
padding: 40px 0 0 40px;
}
p {
font-size: 16px;
line-height: 20px;
text-align: left;
font-family: 'proxima_nova_rgregular', sans-serif;
}
/* Main Wrapper For Everything*/
.weatherwrapper {
height: 1000px;
}
/* Container Housing Both Main Weather Divs*/
.weathercontainer {
margin: 0 auto;
height: 888px;
width: 1046px;
}
/*Left Yellow Div */
.currentweather {
height: 444px;
width: 621px;
float: left;
border-radius: 10px;
background: linear-gradient(134.68deg, #FDDA14 0%, #FDC814 100%);
box-shadow: 0 2px 6px 0 rgba(0,0,0,0.2);
}
/* Current Weather Details */
.currentdetails {
width: 415px;
height: 115px;
align: center;
}
/* Hourly box */
.weathercontent {
height: 142px;
width: 541px;
margin-left: 40px;
border: 1px solid #ECECEC;
border-radius: 10px;
background-color: #FFFFFF;
}
/* Right Grey Div */
.forecast {
height: 444px;
width: 407px;
float: left;
margin-left: 10px;
padding-top: 15px;
border-radius: 10px;
background-color: #686868;
box-shadow: 0 2px 6px 0 rgba(0,0,0,0.2);
}
/* Dividing Line Forcast Div */
.weatherdivider {
height: 1.02px;
width: 100%;
background-color: black;
}
/* Forcast Div For Each Row */
.forecastcontent {
display: inline-block;
width: 407px;
}
.jumbo-padding {
padding: 60px 0;
}
.background-blue {
background-color: #F0F5FB;
}
<div class="weatherwrapper jumbo-padding background-blue">
<div class="weathercontainer">
<h1 align="left">Weather</h1>
<div class="currentweather">
<h3 align="left">Current Weather</h3>
<div class="currentdetails"> 24 degrees address etc </div>
<div class="weathercontent"> </div>
</div>
<div class="forecast">
<div class="forecastcontent">
<h5 style="color: white;"> 5 Day Weather Forecast</h5>
</div>
<div class="weatherdivider"></div>
<div class="forecastcontent">
<h5 style="color: white;">Wednesday</h5>
<p> 19° | 11° </p>
<img src="http://i.imgur.com/Czilat3.png"/>
</div>
<div class="weatherdivider"></div>
<div class="forecastcontent">
<h5 style="color: white;">Thursday</h5>
</div>
<div class="weatherdivider"></div>
<div class="forecastcontent">
<h5 style="color: white;">Friday</h5>
</div>
<div class="weatherdivider"></div>
<div class="forecastcontent">
<h5 style="color: white;">Saturday</h5>
</div>
<div class="weatherdivider"></div>
<div class="forecastcontent">
<h5 style="color: white;">Sunday</h5>
</div>
</div>
</div>
</div>

CSS text alignment and formatting issues

I'd like to center vertically 2 lines of text in a box, but I have 2 questions:
What is the "cleanest" way to reduce the empty space between the main <p> (JOHN DOE) and the <p><span> (born in Japan). I can play with the padding/margin of the <span> line but I don't believe this would be the best approach. Is it?
What is the best way to center these 2 lines of text vertically no matter what the height of the green box is?
Thanks,
https://jsfiddle.net/qa6yzbk7/
<div class="container">
<div class="row">
<div class="col-md-4 intro-boxes white-smoke">
<p>Colum 1</p>
</div>
<div class="col-md-4 intro-boxes apple">
<p>John Doe</p>
<p><span>Born in Japan</span></p>
</div>
<div class="col-md-4 intro-boxes chateau-green">
<p>Jane Doe</p>
<p><span>Born in France</span></p>
</div>
</div>
</div>
CSS:
.chateau-green {
background: #469551;
}
.apple {
background: #6FB34F;
}
.white-smoke {
background: #F5F5F5;
}
.red {
background: red;
}
.green {
background: green;
}
.height-350px {
height: 350px;
background-image: url(http://placehold.it/1350x450/E1E9EC);
background-position: center center;
}
.intro-boxes {
height: 140px;
margin-bottom: 30px;
}
.intro-boxes p {
font-size: 36px;
color: #fff;
text-align: center;
text-transform: uppercase;
}
.intro-boxes p span {
font-size: 18px;
color: #fff;
text-align: center;
text-transform: lowercase;
}
Flexbox for centering....then using line-height and margin/padding resets.
I added borders for visual reference....I also took the span out of the p as it was unnecessary.
.apple {
background: #6FB34F;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
.intro-boxes {
height: 140px;
margin-bottom: 30px;
}
.intro-boxes p {
font-size: 36px;
border: 1px solid grey;
color: #fff;
text-align: center;
text-transform: uppercase;
margin: 0;
padding: 0;
line-height: 1;
}
.intro-boxes span {
font-size: 18px;
border: 1px solid grey;
text-transform: lowercase;
color: white;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" />
<div class="container">
<div class="row">
<div class="col-md-4 intro-boxes apple">
<p>John Doe</p>
<span>Born in Japan</span>
</div>
</div>
</div>