Trang chủCSSBài viết
CSS

Hiệu ứng chiếu sáng (shine effect) (hiệu ứng ánh sáng lướt qua) khi hover vào banner

22/02/2025 977 lượt xem admin Cập nhật: 04/12/2025
5/5 - (667 bình chọn)

Dán CSS sau:

.banner {
    position: relative;
    width: 100%;
    max-width: 800px; /* Điều chỉnh độ rộng banner */
    height: 250px; /* Điều chỉnh chiều cao banner */
    background: url('https://via.placeholder.com/800x250') no-repeat center/cover;
    border-radius: 10px;
    overflow: hidden; /* Ẩn hiệu ứng dư */
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 32px;
    font-weight: bold;
    text-transform: uppercase;
    text-shadow: 2px 2px 10px rgba(0, 0, 0, 0.5);
}


.banner::before {
    content: "";
    position: absolute;
    top: 0;
    left: -100%;
    width: 50%;
    height: 100%;
    background: linear-gradient(to right, rgba(255,255,255,0) 0%, rgba(255,255,255,0.3) 100%);
    transform: skewX(-25deg);
}


.banner:hover::before {
    animation: shine 1s;
}


@keyframes shine {
    100% { left: 150%; }
}

 

Chào ! Bạn thấy nội dung này thế nào?
webdy.vn
webdy.vn

Tạo web nhanh dùng thử miễn phí.

Chia sẻ ↗

Bài liên quan

×