twitter-bootstrap 使用引导 CSS 强制启用外观以只读输入

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/23812365/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 20:46:13  来源:igfitidea点击:

Force enabled look to readonly input with bootstrap CSS

csshtmltwitter-bootstrap

提问by ncohen

I have an app using bootstrap.cssfor the design. I have a readonly input which looks like disabled because of bootstrap (cursor not allowed, background color grey etc...). I would like the input to look enabled with readonly activated.

我有一个使用bootstrap.css进行设计的应用程序。我有一个只读输入,由于引导程序(不允许使用光标,背景颜色灰色等......),它看起来像禁用。我希望输入看起来启用只读激活。

How can I do that?

我怎样才能做到这一点?

edit(adding more code):

编辑(添加更多代码):

Header:

标题:

doctype html
html(ng-app='myApp')
  head
    title=title
    link(rel='stylesheet' href='stylesheets/bootstrap.min-3.1.1.css')
    link(rel='stylesheet' href='stylesheets/style.css')

My input: input.form-control(readonly, placeholder='jj-mm-aaaa')

我的输入: input.form-control(readonly, placeholder='jj-mm-aaaa')

My stylus (style.css):

我的手写笔(style.css):

input[readonly]
  background-color: #fff

回答by quoo

Assuming your custom css is included after the boostrap.css, place the following code in your custom css file

假设您的自定义 css 包含在 boostrap.css 之后,请将以下代码放在您的自定义 css 文件中

input[readonly] {
    background-color: #fff;
    /* any other styles */
}

If you only want to apply this style to specific read only inputs, add a class "exampleclass" to those inputs, and then use:

如果您只想将此样式应用于特定的只读输入,请向这些输入添加一个类“exampleclass”,然后使用:

input[readonly].exampleclass {
   background-color: #fff;
}