:read-only¶
Псевдокласс :read-only
применяется к полям формы, у которых задан атрибут readonly
. Такое поле не может быть модифицировано, при этом оно получает фокус, а данные в таком поле можно выделить и скопировать.
Псевдоклассы
- :active
- :any-link
- :blank
- :checked
- :current()
- :default
- :defined
- :dir()
- :disabled
- :empty
- :enabled
- :first
- :first-child
- :first-of-type
- :focus
- :focus-visible
- :focus-within
- :fullscreen
- :future
- :has()
- :host
- :host()
- :host-context()
- :hover
- :indeterminate
- :in-range
- :invalid
- :is()
- :lang()
- :last-child
- :last-of-type
- :left
- :link
- :local-link
- :not()
- :nth-child()
- :nth-col()
- :nth-last-child()
- :nth-last-col()
- :nth-last-of-type()
- :nth-of-type()
- :only-child
- :only-of-type
- :optional
- :out-of-range
- :past
- :placeholder-shown
- :read-only
- :read-write
- :required
- :right
- :root
- :scope
- :target
- :target-within
- :user-invalid
- :valid
- :visited
- :where()
Синтаксис¶
input:-moz-read-only {
background: #eee;
}
input:read-only {
background: #eee;
}
Спецификации¶
Пример¶
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>:read-only</title>
<style>
input:read-only {
opacity: 0.3; /* Полупрозрачность */
}
</style>
</head>
<body>
<form action="handler.php">
<p>
<input
type="text"
name="comment"
size="40"
value="Введенный текст не может изменяться"
readonly
/>
</p>
<p><input type="submit" value="Отправить" /></p>
</form>
</body>
</html>
См. также¶
Ссылки¶
- Псевдо-класс :read-write MDN (рус.)