How to toggle Effect in Div using only css?

前端 未结 3 1879
自闭症患者
自闭症患者 2021-02-09 06:34

Note: I tried all questions & answers related this topic. Additionally and I tried related questions and try to solve it but not success. So please read m

3条回答
  •  天涯浪人
    2021-02-09 06:49

    You can use a checkbox input and based on if this is checked or not you can show hide the div.

    below is a example using the same.

    .clicker {
      width: 100px;
      height: 100px;
      background-color: blue;
      outline: none;
      cursor: pointer;
      color:#FFF;
      display:block;
    }
    
    .hiddendiv {
      display: none;
      height: 200px;
      background-color: green;
    }
    
    .clicker:focus+.hiddendiv {
      display: block;
    }
    .hidden{
      margin-left:-99999px;
    }
    input#cmn-toggle-7:checked + label + div{
     display:block;
    }

提交回复
热议问题