đī¸ View: card.css
/*=============== GOOGLE FONTS ===============*/
@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@400;500&display=swap");
/*=============== VARIABLES CSS ===============*/
:root {
/*========== Colors ==========*/
/*Color mode HSL(hue, saturation, lightness)*/
--first-color: hsl(82, 60%, 28%);
--title-color: hsl(0, 0%, 15%);
--text-color: hsl(0, 0%, 35%);
--body-color: hsl(0, 0%, 95%);
--container-color: hsl(0, 0%, 100%);
/*========== Font and typography ==========*/
/*.5rem = 8px | 1rem = 16px ...*/
--body-font: "Poppins", sans-serif;
--h2-font-size: 1.25rem;
--small-font-size: 0.813rem;
}
/*========== Responsive typography ==========*/
@media screen and (min-width: 1120px) {
:root {
--h2-font-size: 1.5rem;
--small-font-size: 0.875rem;
}
}
/*=============== BASE ===============*/
* {
box-sizing: border-box;
padding: 0;
margin: 0;
}
body {
font-family: var(--body-font);
background-color: var(--body-color);
color: var(--text-color);
}
/*=============== CARD ===============*/
.container {
display: grid;
place-items: center;
margin-inline: 1.5rem;
padding-block: 1rem;
}
.card__container {
display: grid;
row-gap: 4rem;
padding-block: 3rem;
}
.card__article {
position: relative;
overflow: hidden;
}
.card__img {
width: 200px;
border-radius: 1.5rem;
}
.card__data {
width: 180px;
/* background-color: var(--container-color); */
/* background-color: rgba(210, 210, 210, 0.8); */
padding: 1.5rem 1.5rem;
box-shadow: 0 8px 24px hsla(0, 0%, 8%, 0.15);
border-radius: 1rem;
position: absolute;
bottom: -9rem;
left: 0;
right: 0;
margin-inline: auto;
opacity: 0;
transition: opacity 1s 1s;
}
.card__description {
display: block;
font-size: 1.2rem;
margin-bottom: 0.25rem;
}
.card__title {
font-size: var(--h2-font-size) !important;
font-weight: 500 !important;
color: var(--title-color) !important;
margin-bottom: 0.75rem !important;
}
.card__button {
text-decoration: none;
font-size: var(--small-font-size);
font-weight: 500;
color: var(--first-color);
}
.card__button:hover {
text-decoration: underline;
}
/* Naming animations in hover */
.card__article:hover .card__data {
animation: show-data 1s forwards;
opacity: 1;
transition: opacity 0.3s;
}
.card__article:hover {
animation: remove-overflow 2s forwards;
}
.card__article:not(:hover) {
animation: show-overflow 2s forwards;
}
.card__article:not(:hover) .card__data {
animation: remove-data 1s forwards;
}
/* Card animation */
@keyframes show-data {
50% {
transform: translateY(-10rem);
}
100% {
transform: translateY(-7rem);
}
}
@keyframes remove-overflow {
to {
overflow: initial;
}
}
@keyframes remove-data {
0% {
transform: translateY(-7rem);
}
50% {
transform: translateY(-10rem);
}
100% {
transform: translateY(0.5rem);
}
}
@keyframes show-overflow {
0% {
overflow: initial;
pointer-events: none;
}
50% {
overflow: hidden;
}
}
/*=============== BREAKPOINTS ===============*/
/* For small devices */
@media screen and (max-width: 468px) {
.container {
margin-inline: 1rem;
}
.card__data {
width: 250px;
padding: 1rem;
}
.card__img {
margin-left: 30px;
}
}
/* For medium devices */
@media screen and (min-width: 745px) {
.card__container {
grid-template-columns: repeat(2, 1fr);
column-gap: 4rem;
}
}
/* For large devices */
@media screen and (min-width: 1120px) {
.container {
height: 100vh;
}
.card__container {
grid-template-columns: repeat(4, 1fr);
}
.card__img {
width: 220px;
}
.card__data {
width: 220px;
padding-inline: 2.5rem;
}
}
.img_container {
position: relative;
border: 1px solid #e5e5e5ff;
border-radius: 10px;
}
Size: 3.95 KBMIME: text/plainLines: 216