Style button when :active different from :hover

前端 未结 3 337
深忆病人
深忆病人 2021-01-28 07:37

I want to make a button that displays a background color when hovering and a button color without a background color when the button is down. Here is my current code:

         


        
3条回答
  •  春和景丽
    2021-01-28 07:48

    You have to set a new background color on :hover state

    .windowButton:hover {
        background-color:#1a82b8;
    }
    .windowButton:active {
       fill:#1a82b8;
       background-color:#000000;/*You can put the color you want*/
    }
    

    Pseudo states inherit values. For consistency purposes, it is best to only declare the styles which you are changing in your pseudo state rules.

    Note: :hover MUST come after :link and :visited (if they are present) in the CSS definition, in order to be effective!

提交回复
热议问题