Styling a disabled input with css only

前端 未结 3 1654
北恋
北恋 2020-12-16 10:29

I have sort of a strange situation. I\'m trying to style a disabled input button because I have an annoying hover turning the text to white. This makes it confusing to the

3条回答
  •  [愿得一人]
    2020-12-16 10:59

    Use this CSS (jsFiddle example):

    input:disabled.btn:hover,
    input:disabled.btn:active,
    input:disabled.btn:focus {
      color: green
    }
    

    You have to write the most outer element on the left and the most inner element on the right.

    .btn:hover input:disabled would select any disabled input elements contained in an element with a class btn which is currently hovered by the user.

    I would prefer :disabled over [disabled], see this question for a discussion: Should I use CSS :disabled pseudo-class or [disabled] attribute selector or is it a matter of opinion?


    By the way, Laravel (PHP) generates the HTML - not the browser.

提交回复
热议问题