Trend tạo lá cờ Việt Nam bằng HTML và CSS

coVN
Xem trực tiếp
DEMO:


<!DOCTYPE html>
<html lang="vi">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Cờ Việt Nam</title>
    <link rel="stylesheet" href="style.css">
</head>
<body>
    <div class="flag">
        <div class="star"></div>
    </div>
</body>
</html>

<style>body {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    margin: 0;
    background-color: #f5f5f5;
}

.flag {
    position: relative;
    width: 600px;
    height: 400px;
    background-color: #da251d;
    overflow: hidden;
    animation: slideIn 2s ease-out forwards;
}

.star {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 150px;
    height: 150px;
    background-color: #ffcc00;
    clip-path: polygon(
        50% 0%, 61.8% 35%, 98.5% 35%, 68% 57.6%, 79% 91.6%, 
        50% 70%, 21% 91.6%, 32% 57.6%, 1.5% 35%, 38.2% 35%
    );
    opacity: 0;
    transform: translate(-50%, -50%) scale(0); /* Bắt đầu với kích thước nhỏ */
    animation: zoomIn 2s ease-out 1.5s forwards;
}

/* Hiệu ứng xuất hiện cho cờ */
@keyframes slideIn {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(0);
    }
}

/* Hiệu ứng phóng to cho ngôi sao */
@keyframes zoomIn {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0); /* Bắt đầu với kích thước nhỏ và mờ */
    }
    100% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1); /* Phóng to đến kích thước chuẩn */
    }
}

</style>