:read-only
åºçº¿
广æ³å¯ç¨
èª 2020å¹´7æ èµ·ï¼æ¤ç¹æ§å·²å¨ä¸»æµæµè§å¨ä¸å¾å°æ¯æï¼å¯å¨å¤§å¤æ°è®¾å¤åæµè§å¨çæ¬ä¸æ£å¸¸ä½¿ç¨ã
:read-only CSS 伪类 表示å
ç´ ä¸å¯è¢«ç¨æ·ç¼è¾çç¶æï¼å¦éå®çææ¬è¾å
¥æ¡ï¼ã
css
/* Selects any <input> element that is read-only */
/* Supported in Firefox with a prefix */
input:-moz-read-only {
background-color: #ccc;
}
/* Supported in Blink/WebKit/Edge without a prefix */
input:read-only {
background-color: #ccc;
}
è¯æ³
Error: could not find syntax for this item示ä¾
>HTML
html
<input type="text" value="Type whatever you want here." />
<input type="text" value="This is a read-only field." readonly />
<p>This is a normal paragraph.</p>
<p contenteditable="true">You can edit this paragraph!</p>
CSS
css
input {
min-width: 25em;
}
input:-moz-read-only {
background: cyan;
}
input:read-only {
background: cyan;
}
p:-moz-read-only {
background: lightgray;
}
p:read-only {
background: lightgray;
}
p[contenteditable="true"] {
color: blue;
}
ç»æ
è§è
| è§è |
|---|
| HTML> # selector-read-only> |
| Selectors Level 4> # read-only-pseudo> |
æµè§å¨å ¼å®¹æ§
åè§
:read-write- HTML
contenteditableattribute