Disable a textbox using CSS

前端 未结 9 1201
粉色の甜心
粉色の甜心 2020-12-24 00:23

How to disable a textbox in CSS? Currently we are having a textbox in our view which can be enabled/disabled depending on a property in the model. We are having asp.net MVC

9条回答
  •  生来不讨喜
    2020-12-24 01:01

    You can't disable a textbox in CSS. Disabling it is not a presentational task, you will have to do this in the HTML markup using the disabled attribute.

    You may be able to put something together by putting the textbox underneath an absolutely positioned transparent element with z-index... But that's just silly, plus you would need a second HTML element anyway.

    You can, however, style disabled text boxes (if that's what you mean) in CSS using

    input[disabled] { ... }
    

    from IE7 upwards and in all other major browsers.

提交回复
热议问题