Fill element from center on hover

后端 未结 3 2285
自闭症患者
自闭症患者 2020-12-28 09:36

How can I create a button so that on hover the background colour fills the element from center to left and right of the element.

Example :

3条回答
  •  独厮守ぢ
    2020-12-28 09:55

    you can do a button with this structure

    
    
    
    
    on.hover -> button > image
    transform-origin: center
    insert desired effect here
    

    *edit -- seems like you want the text the have color changes while transition is happening..

    you can do a 2 image button inside a div on hover hide the whtie background image and display the div that contains the brown image

    Set the width of container to 0 pix and fix it to the center and then animate just the width will give you the desired results.

提交回复
热议问题