Make background fade out/in

后端 未结 3 423
刺人心
刺人心 2020-12-17 10:03

Is there any way I can use CSS3 to fade in and out a solid white background of a

? the content should remain visible so just the background should fa
相关标签:
3条回答
  • 2020-12-17 10:35

    You may find this useful for examples of image and background color fades: - http://nettuts.s3.amazonaws.com/581_cssTransitions/demos.html

    However using CSS 3 to do the transition will limit the effect to browsers that don't support it.

    0 讨论(0)
  • 2020-12-17 10:38

    You could have two divs in one container div. The first div contains the white background, the second one gets the content.

    Then, use a CSS3 transform to animate the opacity of the first div to zero.

    0 讨论(0)
  • 2020-12-17 10:56

    Sure, you can use the transition property directly on the background-color:

    div {
       background-color: white;    
    
       /* transition the background-color over 1s with a linear animation */
       transition: background-color 1s linear;
    }
    
    /* the :hover that causes the background-color to change */
    div:hover {
       background-color: transparent;      
    }
    

    Here's an example of a red background fading out on :hover.

    0 讨论(0)
提交回复
热议问题