IE 11 Bug - Image inside label inside form

前端 未结 7 1716
面向向阳花
面向向阳花 2021-02-18 13:13

In IE11, the following piece of code will check the radio button as expected:



7条回答
  •  执念已碎
    2021-02-18 13:52

    As I answered previously in the referred question, there is a pure CSS way.

    If your image is display: block that fix can still be used, even tho you have to add some more trickery. For example:

    CSS:

    label img{
        display: block; /* requirement */
        /* fix */
        pointer-events: none;
        position: relative;
    }
    
    /* fix */
    label{
        display: inline-block;
        position: relative;
    }
    label::before{
        content: "";
        display: block;
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: -1;
    }
    

    HTML:

    Fiddle

    If the problem is with click handlers on the image it self, you may be able to solve that with a wrapper element on the image instead (which maybe the label, so no extra element may be needed). (But for that I'd like to see a more specific example that you are trying to do.)

提交回复
热议问题