Fade out after div content has been shown using CSS

前端 未结 3 575
有刺的猬
有刺的猬 2021-01-18 02:50

I\'m trying to show a notification on button click. The button click actually checks for email validation. I know to show a div with content with the error message. However,

3条回答
  •  终归单人心
    2021-01-18 03:31

    Using css3 keyframe animation:

    (You'll probably want to add -webkit- -moz-, -ms-, and -o- prefixes on the animation and animation-delay properties inside .error-message and on the keyframes to support older browsers.)

    .error-message {
        animation: fadeOut 2s forwards;
        animation-delay: 5s;
        background: red;
        color: white;
        padding: 10px;
        text-align: center;
    }
    
    @keyframes fadeOut {
        from {opacity: 1;}
        to {opacity: 0;}
    }

    Some random text

提交回复
热议问题