Título
Descripción
卡片(tarjetas)是现代网络中多功能的组件。利用简洁明了的信息和视觉吸引力呈现信息,通过博客提供在线文章和产品。现在,我们将探索不同的实施方式和最佳实践。
含有各种元素的卡片:
![]()
Título de la Card
Descripción o contenido principal
.card {
width: 300px;
border-radius: 8px;
overflow: hidden;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
transition: transform 0.2s ease;
}
.card:hover {
transform: translateY(-4px);
}
.card-image {
width: 100%;
height: 200px;
object-fit: cover;
}
.card-content {
padding: 16px;
}
.card-title {
margin: 0 0 8px;
font-size: 1.25rem;
}
.card-description {
color: #666;
line-height: 1.5;
}
.card-footer {
display: flex;
justify-content: space-between;
align-items: center;
padding-top: 16px;
margin-top: 16px;
border-top: 1px solid #eee;
}![]()
Título de la Card
Descripción o contenido principal
Meta info
interface CardProps {
image: string;
title: string;
description: string;
action?: () => void;
meta?: string;
}
const Card: React.FC = ({
image,
title,
description,
action,
meta
}) => {
return (
{title}
{description}
{action && (
)}
{meta && {meta}}
);
}; ![]()
{{ title }}
{{ description }}
.card-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
gap: 24px;
padding: 24px;
}.card-image-container {
position: relative;
padding-top: 56.25%; /* 16:9 Aspect Ratio */
}
.card-image {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
object-fit: cover;
}.card-skeleton {
animation: pulse 1.5s infinite;
}
@keyframes pulse {
0% { opacity: 0.6; }
50% { opacity: 1; }
100% { opacity: 0.6; }
}![]()
Título
Descripción
import Image from 'next/image';
const handleImageError = (e: React.SyntheticEvent) => { e.currentTarget.src = '/placeholder.jpg'; };
.card-title {
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
}/* Hover Effects */
.card {
transition: all 0.3s ease;
}
.card:hover {
transform: translateY(-4px);
box-shadow: 0 12px 24px rgba(0, 0, 0, 0.15);
}
/* Click Effect */
.card:active {
transform: translateY(-2px);
box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
}useEffect(() => {
const observer = new IntersectionObserver(
(entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
// Cargar contenido
}
});
},
{ threshold: 0.1 }
);
observer.observe(cardRef.current);
return () => observer.disconnect();
}, []);卡是现代网络设计的基本组件。请考虑实施: