Computer >> Hướng Dẫn Máy Tính >  >> Lập Trình >> CSS

Đặt tốc độ hiệu ứng hover với CSS (transition-duration)

Giới thiệu

Để đặt tốc độ cho hiệu ứng hover, sử dụng thuộc tính transition-duration. Để tạo hiệu ứng hover, sử dụng bộ chọn :hover.

Ví dụ

<!DOCTYPE html>
<html>
<head>
    <style>
        .btn {
            background-color: yellow;
            color: black;
            text-align: center;
            font-size: 15px;
            padding: 20px;
            border-radius: 15px;
            border: 3px dashed blue;
            transition-duration: 2s;
        }
        .btn:hover {
            background-color: orange;
            color: black;
            border: 3px solid blue;
        }
    </style>
</head>
<body>
    <h2>Kết quả</h2>
    <p>Nhấn bên dưới để xem kết quả:</p>
    <button class="btn">Kết quả</button>
</body>
</html>