Issue
I am trying create a responsive UI cards out of the card the design below for dynamic content. The current design shrinks the cards and their content instead of rearranging the cards as the screen gets smaller. This is the current cards designs.
@import url("https://fonts.googleapis.com/css2?family=Inter:wght@300;400;600;700&display=swap");
/***** CSS VARIABLES *****/
/***** CSS RESET *****/
*,
*:before,
*:after {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
margin: 0;
padding: 0;
height: 100vh;
width: 100vw;
display: flex;
justify-content: center;
align-items: center;
overflow: hidden;
background: #15202b;
font-family: "Inter", sans-serif;
color: white;
}
img {
height: 100%;
width: 100%;
object-fit: cover;
}
a {
text-decoration: none;
}
.card {
height: 250px;
width: 440px;
border: 1px solid #38444c;
padding: 1rem;
}
.card article {
margin-top: 0.5rem;
}
.card article p {
font-size: 1.15em;
}
.profile {
margin-top: 20px;
display: flex;
align-items: center;
}
.image {
width: 55px;
height: 55px;
border-radius: 50%;
}
.image img {
border-radius: 50%;
}
.username {
margin-left: 10px;
}
.username h4 {
font-size: 0.9rem;
}
.username span {
color: #566471;
font-size: 0.85rem;
}
.tweet-info {
display: flex;
align-items: center;
gap: 3px;
padding: 1rem 0;
border-bottom: 1px solid #38444c;
}
.tweet-info span {
font-size: 0.85rem;
color: #566471;
}
.heart {
cursor: pointer;
height: 50px;
width: 50px;
background-image: url("https://abs.twimg.com/a/1446542199/img/t1/web_heart_animation.png");
background-position: left;
background-repeat: no-repeat;
background-size: 3000%;
}
.is_animating {
animation: heart-burst 0.8s steps(28) 1;
}
@keyframes heart-burst {
from {
background-position: left;
}
to {
background-position: right;
}
}
M
<!DOCTYPE html>
<html lang="en" >
<head>
<meta charset="UTF-8">
<title>CodePen - Twitter Like Animation 💖</title>
<link rel="stylesheet" href="./style.css">
</head>
<body>
<!-- partial:index.partial.html -->
<div class='card'>
<div class='profile'>
<div class='image'>
<img src='https://pbs.twimg.com/profile_images/1420218664763068416/E5M2zbLg_400x400.jpg' alt='profile image' />
</div>
<div class='username'>
<h4>Ayush</h4>
<a href='https://twitter.com/ayushgptaa' target='_blank'> <span>@ayushgptaa</span></a>
</div>
</div>
<article>
<p>Hey Lovely people, I Created this Twitter card using CSS🚀👾</p>
</article>
<div class='tweet-info'>
<span>4:20AM ·</span> <span> Jul 26, 2021 · </span><span>Twitter Web App</span>
</div>
<div class='icons'>
<svg viewBox="0 0 24 24" aria-hidden="true" class="r-4qtqp9 r-yyyyoo r-50lct3 r-dnmrzs r-bnwqim r-1plcrui r-lrvibr r-1srniue">
<g>
<path d="M14.046 2.242l-4.148-.01h-.002c-4.374 0-7.8 3.427-7.8 7.802 0 4.098 3.186 7.206 7.465 7.37v3.828c0 .108.044.286.12.403.142.225.384.347.632.347.138 0 .277-.038.402-.118.264-.168 6.473-4.14 8.088-5.506 1.902-1.61 3.04-3.97 3.043-6.312v-.017c-.006-4.367-3.43-7.787-7.8-7.788zm3.787 12.972c-1.134.96-4.862 3.405-6.772 4.643V16.67c0-.414-.335-.75-.75-.75h-.396c-3.66 0-6.318-2.476-6.318-5.886 0-3.534 2.768-6.302 6.3-6.302l4.147.01h.002c3.532 0 6.3 2.766 6.302 6.296-.003 1.91-.942 3.844-2.514 5.176z"></path>
</g>
</svg>
<svg viewBox="0 0 24 24" aria-hidden="true" class="r-4qtqp9 r-yyyyoo r-50lct3 r-dnmrzs r-bnwqim r-1plcrui r-lrvibr r-1srniue">
<g>
<path d="M23.77 15.67c-.292-.293-.767-.293-1.06 0l-2.22 2.22V7.65c0-2.068-1.683-3.75-3.75-3.75h-5.85c-.414 0-.75.336-.75.75s.336.75.75.75h5.85c1.24 0 2.25 1.01 2.25 2.25v10.24l-2.22-2.22c-.293-.293-.768-.293-1.06 0s-.294.768 0 1.06l3.5 3.5c.145.147.337.22.53.22s.383-.072.53-.22l3.5-3.5c.294-.292.294-.767 0-1.06zm-10.66 3.28H7.26c-1.24 0-2.25-1.01-2.25-2.25V6.46l2.22 2.22c.148.147.34.22.532.22s.384-.073.53-.22c.293-.293.293-.768 0-1.06l-3.5-3.5c-.293-.294-.768-.294-1.06 0l-3.5 3.5c-.294.292-.294.767 0 1.06s.767.293 1.06 0l2.22-2.22V16.7c0 2.068 1.683 3.75 3.75 3.75h5.85c.414 0 .75-.336.75-.75s-.337-.75-.75-.75z"></path>
</g>
</svg>
<div class="heart"></div>
<svg viewBox="0 0 24 24" aria-hidden="true" class="r-4qtqp9 r-yyyyoo r-50lct3 r-dnmrzs r-bnwqim r-1plcrui r-lrvibr r-1srniue">
<g>
<path d="M17.53 7.47l-5-5c-.293-.293-.768-.293-1.06 0l-5 5c-.294.293-.294.768 0 1.06s.767.294 1.06 0l3.72-3.72V15c0 .414.336.75.75.75s.75-.336.75-.75V4.81l3.72 3.72c.146.147.338.22.53.22s.384-.072.53-.22c.293-.293.293-.767 0-1.06z"></path>
<path d="M19.708 21.944H4.292C3.028 21.944 2 20.916 2 19.652V14c0-.414.336-.75.75-.75s.75.336.75.75v5.652c0 .437.355.792.792.792h15.416c.437 0 .792-.355.792-.792V14c0-.414.336-.75.75-.75s.75.336.75.75v5.652c0 1.264-1.028 2.292-2.292 2.292z"></path>
</g>
</svg>
</div>
</div>
<br>
<!-- partial:index.partial.html -->
<div class='card'>
<div class='profile'>
<div class='image'>
<img src='https://pbs.twimg.com/profile_images/1420218664763068416/E5M2zbLg_400x400.jpg' alt='profile image' />
</div>
<div class='username'>
<h4>Ayush</h4>
<a href='https://twitter.com/ayushgptaa' target='_blank'> <span>@ayushgptaa</span></a>
</div>
</div>
<article>
<p>Hey Lovely people, I Created this Twitter card using CSS🚀👾</p>
</article>
<div class='tweet-info'>
<span>4:20AM ·</span> <span> Jul 26, 2021 · </span><span>Twitter Web App</span>
</div>
<div class='icons'>
<svg viewBox="0 0 24 24" aria-hidden="true" class="r-4qtqp9 r-yyyyoo r-50lct3 r-dnmrzs r-bnwqim r-1plcrui r-lrvibr r-1srniue">
<g>
<path d="M14.046 2.242l-4.148-.01h-.002c-4.374 0-7.8 3.427-7.8 7.802 0 4.098 3.186 7.206 7.465 7.37v3.828c0 .108.044.286.12.403.142.225.384.347.632.347.138 0 .277-.038.402-.118.264-.168 6.473-4.14 8.088-5.506 1.902-1.61 3.04-3.97 3.043-6.312v-.017c-.006-4.367-3.43-7.787-7.8-7.788zm3.787 12.972c-1.134.96-4.862 3.405-6.772 4.643V16.67c0-.414-.335-.75-.75-.75h-.396c-3.66 0-6.318-2.476-6.318-5.886 0-3.534 2.768-6.302 6.3-6.302l4.147.01h.002c3.532 0 6.3 2.766 6.302 6.296-.003 1.91-.942 3.844-2.514 5.176z"></path>
</g>
</svg>
<svg viewBox="0 0 24 24" aria-hidden="true" class="r-4qtqp9 r-yyyyoo r-50lct3 r-dnmrzs r-bnwqim r-1plcrui r-lrvibr r-1srniue">
<g>
<path d="M23.77 15.67c-.292-.293-.767-.293-1.06 0l-2.22 2.22V7.65c0-2.068-1.683-3.75-3.75-3.75h-5.85c-.414 0-.75.336-.75.75s.336.75.75.75h5.85c1.24 0 2.25 1.01 2.25 2.25v10.24l-2.22-2.22c-.293-.293-.768-.293-1.06 0s-.294.768 0 1.06l3.5 3.5c.145.147.337.22.53.22s.383-.072.53-.22l3.5-3.5c.294-.292.294-.767 0-1.06zm-10.66 3.28H7.26c-1.24 0-2.25-1.01-2.25-2.25V6.46l2.22 2.22c.148.147.34.22.532.22s.384-.073.53-.22c.293-.293.293-.768 0-1.06l-3.5-3.5c-.293-.294-.768-.294-1.06 0l-3.5 3.5c-.294.292-.294.767 0 1.06s.767.293 1.06 0l2.22-2.22V16.7c0 2.068 1.683 3.75 3.75 3.75h5.85c.414 0 .75-.336.75-.75s-.337-.75-.75-.75z"></path>
</g>
</svg>
<div class="heart"></div>
<svg viewBox="0 0 24 24" aria-hidden="true" class="r-4qtqp9 r-yyyyoo r-50lct3 r-dnmrzs r-bnwqim r-1plcrui r-lrvibr r-1srniue">
<g>
<path d="M17.53 7.47l-5-5c-.293-.293-.768-.293-1.06 0l-5 5c-.294.293-.294.768 0 1.06s.767.294 1.06 0l3.72-3.72V15c0 .414.336.75.75.75s.75-.336.75-.75V4.81l3.72 3.72c.146.147.338.22.53.22s.384-.072.53-.22c.293-.293.293-.767 0-1.06z"></path>
<path d="M19.708 21.944H4.292C3.028 21.944 2 20.916 2 19.652V14c0-.414.336-.75.75-.75s.75.336.75.75v5.652c0 .437.355.792.792.792h15.416c.437 0 .792-.355.792-.792V14c0-.414.336-.75.75-.75s.75.336.75.75v5.652c0 1.264-1.028 2.292-2.292 2.292z"></path>
</g>
</svg>
</div>
</div>
<!-- partial -->
<script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js'></script>
<script src="./script.js"></script>
</body>
</html>
I would like the cards to behave like this codepen responsive card design
how can i create a responsive row of cards out the card design ?
Solution
FLEX-WRAP:WRAP IS VERY IMPORTANT HERE The flex-wrap property specifies whether the flexible items should wrap or not. ** WE APPLY FLEX-WRAP TO FLEX ITEM SO WHEN SCREEN SIZE SHRINKS OVERFLOWED CONTENT WILL BE SET TO NEW LINE. (I WOULD RECOMMEND YOU TO WRAP CARD IN CARD CONTAINER AND THA APPLY DISPLAY FLEX INSTEAD OF APPLYING DIRECTLY TO BODY)**
@import url("https://fonts.googleapis.com/css2?family=Inter:wght@300;400;600;700&display=swap");
/***** CSS VARIABLES *****/
/***** CSS RESET *****/
*,
*:before,
*:after {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
margin: 0;
padding: 0;
height: 100vh;
width: 100vw;
display: flex;
justify-content: center;
align-items: center;
flex-wrap:wrap; /*to wrap overflowed content*/
overflow-x: hidden; /*to show vertically overflowed content*/
background: #15202b;
font-family: "Inter", sans-serif;
color: white;
}
img {
height: 100%;
width: 100%;
object-fit: cover;
}
a {
text-decoration: none;
}
.card {
height: 250px;
width: 440px;
border: 1px solid #38444c;
padding: 1rem;
}
.card article {
margin-top: 0.5rem;
}
.card article p {
font-size: 1.15em;
}
.profile {
margin-top: 20px;
display: flex;
align-items: center;
}
.image {
width: 55px;
height: 55px;
border-radius: 50%;
}
.image img {
border-radius: 50%;
}
.username {
margin-left: 10px;
}
.username h4 {
font-size: 0.9rem;
}
.username span {
color: #566471;
font-size: 0.85rem;
}
.tweet-info {
display: flex;
align-items: center;
gap: 3px;
padding: 1rem 0;
border-bottom: 1px solid #38444c;
}
.tweet-info span {
font-size: 0.85rem;
color: #566471;
}
.heart {
cursor: pointer;
height: 50px;
width: 50px;
background-image: url("https://abs.twimg.com/a/1446542199/img/t1/web_heart_animation.png");
background-position: left;
background-repeat: no-repeat;
background-size: 3000%;
}
.is_animating {
animation: heart-burst 0.8s steps(28) 1;
}
@keyframes heart-burst {
from {
background-position: left;
}
to {
background-position: right;
}
}
M
<!DOCTYPE html>
<html lang="en" >
<head>
<meta charset="UTF-8">
<title>CodePen - Twitter Like Animation 💖</title>
<link rel="stylesheet" href="./style.css">
</head>
<body>
<!-- partial:index.partial.html -->
<div class='card'>
<div class='profile'>
<div class='image'>
<img src='https://pbs.twimg.com/profile_images/1420218664763068416/E5M2zbLg_400x400.jpg' alt='profile image' />
</div>
<div class='username'>
<h4>Ayush</h4>
<a href='https://twitter.com/ayushgptaa' target='_blank'> <span>@ayushgptaa</span></a>
</div>
</div>
<article>
<p>Hey Lovely people, I Created this Twitter card using CSS🚀👾</p>
</article>
<div class='tweet-info'>
<span>4:20AM ·</span> <span> Jul 26, 2021 · </span><span>Twitter Web App</span>
</div>
<div class='icons'>
<svg viewBox="0 0 24 24" aria-hidden="true" class="r-4qtqp9 r-yyyyoo r-50lct3 r-dnmrzs r-bnwqim r-1plcrui r-lrvibr r-1srniue">
<g>
<path d="M14.046 2.242l-4.148-.01h-.002c-4.374 0-7.8 3.427-7.8 7.802 0 4.098 3.186 7.206 7.465 7.37v3.828c0 .108.044.286.12.403.142.225.384.347.632.347.138 0 .277-.038.402-.118.264-.168 6.473-4.14 8.088-5.506 1.902-1.61 3.04-3.97 3.043-6.312v-.017c-.006-4.367-3.43-7.787-7.8-7.788zm3.787 12.972c-1.134.96-4.862 3.405-6.772 4.643V16.67c0-.414-.335-.75-.75-.75h-.396c-3.66 0-6.318-2.476-6.318-5.886 0-3.534 2.768-6.302 6.3-6.302l4.147.01h.002c3.532 0 6.3 2.766 6.302 6.296-.003 1.91-.942 3.844-2.514 5.176z"></path>
</g>
</svg>
<svg viewBox="0 0 24 24" aria-hidden="true" class="r-4qtqp9 r-yyyyoo r-50lct3 r-dnmrzs r-bnwqim r-1plcrui r-lrvibr r-1srniue">
<g>
<path d="M23.77 15.67c-.292-.293-.767-.293-1.06 0l-2.22 2.22V7.65c0-2.068-1.683-3.75-3.75-3.75h-5.85c-.414 0-.75.336-.75.75s.336.75.75.75h5.85c1.24 0 2.25 1.01 2.25 2.25v10.24l-2.22-2.22c-.293-.293-.768-.293-1.06 0s-.294.768 0 1.06l3.5 3.5c.145.147.337.22.53.22s.383-.072.53-.22l3.5-3.5c.294-.292.294-.767 0-1.06zm-10.66 3.28H7.26c-1.24 0-2.25-1.01-2.25-2.25V6.46l2.22 2.22c.148.147.34.22.532.22s.384-.073.53-.22c.293-.293.293-.768 0-1.06l-3.5-3.5c-.293-.294-.768-.294-1.06 0l-3.5 3.5c-.294.292-.294.767 0 1.06s.767.293 1.06 0l2.22-2.22V16.7c0 2.068 1.683 3.75 3.75 3.75h5.85c.414 0 .75-.336.75-.75s-.337-.75-.75-.75z"></path>
</g>
</svg>
<div class="heart"></div>
<svg viewBox="0 0 24 24" aria-hidden="true" class="r-4qtqp9 r-yyyyoo r-50lct3 r-dnmrzs r-bnwqim r-1plcrui r-lrvibr r-1srniue">
<g>
<path d="M17.53 7.47l-5-5c-.293-.293-.768-.293-1.06 0l-5 5c-.294.293-.294.768 0 1.06s.767.294 1.06 0l3.72-3.72V15c0 .414.336.75.75.75s.75-.336.75-.75V4.81l3.72 3.72c.146.147.338.22.53.22s.384-.072.53-.22c.293-.293.293-.767 0-1.06z"></path>
<path d="M19.708 21.944H4.292C3.028 21.944 2 20.916 2 19.652V14c0-.414.336-.75.75-.75s.75.336.75.75v5.652c0 .437.355.792.792.792h15.416c.437 0 .792-.355.792-.792V14c0-.414.336-.75.75-.75s.75.336.75.75v5.652c0 1.264-1.028 2.292-2.292 2.292z"></path>
</g>
</svg>
</div>
</div>
<br>
<!-- partial:index.partial.html -->
<div class='card'>
<div class='profile'>
<div class='image'>
<img src='https://pbs.twimg.com/profile_images/1420218664763068416/E5M2zbLg_400x400.jpg' alt='profile image' />
</div>
<div class='username'>
<h4>Ayush</h4>
<a href='https://twitter.com/ayushgptaa' target='_blank'> <span>@ayushgptaa</span></a>
</div>
</div>
<article>
<p>Hey Lovely people, I Created this Twitter card using CSS🚀👾</p>
</article>
<div class='tweet-info'>
<span>4:20AM ·</span> <span> Jul 26, 2021 · </span><span>Twitter Web App</span>
</div>
<div class='icons'>
<svg viewBox="0 0 24 24" aria-hidden="true" class="r-4qtqp9 r-yyyyoo r-50lct3 r-dnmrzs r-bnwqim r-1plcrui r-lrvibr r-1srniue">
<g>
<path d="M14.046 2.242l-4.148-.01h-.002c-4.374 0-7.8 3.427-7.8 7.802 0 4.098 3.186 7.206 7.465 7.37v3.828c0 .108.044.286.12.403.142.225.384.347.632.347.138 0 .277-.038.402-.118.264-.168 6.473-4.14 8.088-5.506 1.902-1.61 3.04-3.97 3.043-6.312v-.017c-.006-4.367-3.43-7.787-7.8-7.788zm3.787 12.972c-1.134.96-4.862 3.405-6.772 4.643V16.67c0-.414-.335-.75-.75-.75h-.396c-3.66 0-6.318-2.476-6.318-5.886 0-3.534 2.768-6.302 6.3-6.302l4.147.01h.002c3.532 0 6.3 2.766 6.302 6.296-.003 1.91-.942 3.844-2.514 5.176z"></path>
</g>
</svg>
<svg viewBox="0 0 24 24" aria-hidden="true" class="r-4qtqp9 r-yyyyoo r-50lct3 r-dnmrzs r-bnwqim r-1plcrui r-lrvibr r-1srniue">
<g>
<path d="M23.77 15.67c-.292-.293-.767-.293-1.06 0l-2.22 2.22V7.65c0-2.068-1.683-3.75-3.75-3.75h-5.85c-.414 0-.75.336-.75.75s.336.75.75.75h5.85c1.24 0 2.25 1.01 2.25 2.25v10.24l-2.22-2.22c-.293-.293-.768-.293-1.06 0s-.294.768 0 1.06l3.5 3.5c.145.147.337.22.53.22s.383-.072.53-.22l3.5-3.5c.294-.292.294-.767 0-1.06zm-10.66 3.28H7.26c-1.24 0-2.25-1.01-2.25-2.25V6.46l2.22 2.22c.148.147.34.22.532.22s.384-.073.53-.22c.293-.293.293-.768 0-1.06l-3.5-3.5c-.293-.294-.768-.294-1.06 0l-3.5 3.5c-.294.292-.294.767 0 1.06s.767.293 1.06 0l2.22-2.22V16.7c0 2.068 1.683 3.75 3.75 3.75h5.85c.414 0 .75-.336.75-.75s-.337-.75-.75-.75z"></path>
</g>
</svg>
<div class="heart"></div>
<svg viewBox="0 0 24 24" aria-hidden="true" class="r-4qtqp9 r-yyyyoo r-50lct3 r-dnmrzs r-bnwqim r-1plcrui r-lrvibr r-1srniue">
<g>
<path d="M17.53 7.47l-5-5c-.293-.293-.768-.293-1.06 0l-5 5c-.294.293-.294.768 0 1.06s.767.294 1.06 0l3.72-3.72V15c0 .414.336.75.75.75s.75-.336.75-.75V4.81l3.72 3.72c.146.147.338.22.53.22s.384-.072.53-.22c.293-.293.293-.767 0-1.06z"></path>
<path d="M19.708 21.944H4.292C3.028 21.944 2 20.916 2 19.652V14c0-.414.336-.75.75-.75s.75.336.75.75v5.652c0 .437.355.792.792.792h15.416c.437 0 .792-.355.792-.792V14c0-.414.336-.75.75-.75s.75.336.75.75v5.652c0 1.264-1.028 2.292-2.292 2.292z"></path>
</g>
</svg>
</div>
</div>
<!-- partial -->
<script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js'></script>
<script src="./script.js"></script>
</body>
</html>
Answered By - Nikkkshit
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.