Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Force enabled look to readonly input with bootstrap CSS

I have an app using bootstrap.css for 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.

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')

My stylus (style.css):

input[readonly]
  background-color: #fff
like image 821
ncohen Avatar asked May 22 '14 16:05

ncohen


People also ask

Is it possible to make input fields read only through CSS?

Pure CSS Form Read-Only Inputs Class: There is no class for that we have a predefined attribute that can make any input field read-only and that attribute is readonly=” ” with empty value.

How do I use readonly in CSS?

The :read-only selector selects elements which are "readonly". Form elements with a "readonly" attribute are defined as "readonly".

How do I make a textbox readonly in CSS?

css cannot be used for making an input readonly. You can use jquery or simple javascript to change the prperty of the fields.

How do you make a text box readonly in bootstrap?

If you want to have <input readonly> elements in your form styled as plain text, use the .form-control-plaintext class to remove the default form field styling and preserve the correct margin and padding.


1 Answers

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

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:

input[readonly].exampleclass {
   background-color: #fff;
}
like image 106
quoo Avatar answered Oct 21 '22 12:10

quoo