Button inside a label

后端 未结 5 1045
后悔当初
后悔当初 2021-02-12 15:20

I have a label with \"for=\"the pointer to the checkbox input\"\" and as long as I know, this for can be added only for label

5条回答
  •  借酒劲吻你
    2021-02-12 15:51

    You can use transparent pseudo element that overlays the checkbox and the button itself that will catch mouse events.

    Here's an example:

    html:

    
    

    css:

    .disable{pointer-events:fill}
    label{position:relative}
    label:after{
      position: absolute;
      content: "";
      width: 100%;
      height: 100%;
      background: transparent;
      top:0;
      left:0;
      right:0;
      bottom:0;
    }
    

提交回复
热议问题