How to keep :active css style after click a button

后端 未结 3 1552
不知归路
不知归路 2020-12-08 00:44

Once the button is clicked I want it to stay with the active style instead of going back to normal style. Can this be done with CSS please? Im using blurb button from DIVI

3条回答
  •  北海茫月
    2020-12-08 01:10

    I FIGURED IT OUT. SIMPLE, EFFECTIVE NO jQUERY

    We're going to to be using a hidden checkbox.
    This example includes one "on click - off click 'hover / active' state"

    --

    To make content itself clickable:

    HTML

    
      
    

    CSS

    #activate-div{display:none}    
    
    .my-div{background-color:#FFF} 
    
    #activate-div:checked ~ label 
    .my-div{background-color:#000}
    



    To make button change content:

    HTML

    
       
    //MY DIV CONTENT

    CSS

    #activate-div{display:none}
    
    .my-div{background-color:#FFF} 
    
    #activate-div:checked + 
    .my-div{background-color:#000}
    

    Hope it helps!!

提交回复
热议问题