CSS3 selector: read-only selector CSS3 selector: Read-write Selector

Source: Internet
Author: User

CSS3 selector: read-only Selector

The ": Read-only" pseudo-class selector is used to specify the style of elements that are in a read-only state. The simple point of understanding is that "readonly= ' ReadOnly" is set in the element

Sample Demo

Use the ": Read-only" selector to set the style of the Address text box.

HTML code:

<form action= "#" >  <div>    <label for= "name" > name:</label> <input    type= "text" Name= "name" id= "name" placeholder= "Desert"/>  </div>  <div>    <label for= "Address" > Addresses: </label>    <input type= "text" name= "Address" id= "address" placeholder= "Shanghai, China" readonly= "readonly"/>  </div></form>  


CSS code:

form {  width:300px;  padding:10px;  border:1px solid #ccc;  margin:50px Auto;} form > div {  margin-bottom:10px;} Input[type= "text"]{  border:1px solid orange;  padding:5px;  Background: #fff;  border-radius:5px;} Input[type= "text"]:-moz-read-only{  border-color: #ccc;} Input[type= "text"]:read-only{  border-color: #ccc;}

Results Demo

CSS3 selector: Read-write Selector

The ": Read-write" selector is just the opposite of the ": Read-only" selector, which is used primarily to specify the style when the element is in a non-read-only state.

Sample Demo

Use the ": Read-write" selector to set the text box style that is not a read-only control.

HTML code:

<form action= "#" >  <div>    <label for= "name" > name:</label> <input    type= "text" Name= "name" id= "name" placeholder= "Desert"/>  </div>  <div>    <label for= "Address" > Addresses: </label>    <input type= "text" name= "Address" id= "address" placeholder= "Shanghai, China" readonly= "readonly"/>  </div></form>  

CSS code:

form {  width:300px;  padding:10px;  border:1px solid #ccc;  margin:50px Auto;} form > div {  margin-bottom:10px;} Input[type= "text"]{  border:1px solid orange;  padding:5px;  Background: #fff;  border-radius:5px;} Input[type= "text"]:-moz-read-only{  border-color: #ccc;} Input[type= "text"]:read-only{  border-color: #ccc;} Input[type= "text"]:-moz-read-write{  border-color: #f36;} Input[type= "text"]:read-write{  border-color: #f36;}

Results Demo:

CSS3 selector: read-only selector CSS3 selector: Read-write selector

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.