How to style a HTML label for disabled input

后端 未结 5 1116
遇见更好的自我
遇见更好的自我 2020-12-29 03:16

I would like the labels for my form elements to be greyed out if the input is disabled and am not able to get it to work for text inputs. I have tried the following:

<
5条回答
  •  星月不相逢
    2020-12-29 03:43

    I had the same issue: make a read-only input EXACTLY like label, I add a set of css styles to the input to get to that goal:

    
    

    And in CSS:

    .inputLikeLabel {
        background-color: #ffffff;
        text-align: center;
        border: none;
        cursor: none;
        pointer-events: none;
    }
    

    By the css style, the input has a white background with no border, no mouse cursor and no click event...similar to label by the end !

提交回复
热议问题