diff options
Diffstat (limited to 'files/vi/web/css/_colon_focus-within/index.html')
| -rw-r--r-- | files/vi/web/css/_colon_focus-within/index.html | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/files/vi/web/css/_colon_focus-within/index.html b/files/vi/web/css/_colon_focus-within/index.html new file mode 100644 index 0000000000..3c39e176fa --- /dev/null +++ b/files/vi/web/css/_colon_focus-within/index.html @@ -0,0 +1,88 @@ +--- +title: ':focus-within' +slug: 'Web/CSS/:focus-within' +translation_of: 'Web/CSS/:focus-within' +--- +<div>{{CSSRef}}</div> + +<p><a href="/en-US/docs/Web/CSS/Pseudo-classes">Lớp giả</a> <a href="/en-US/docs/Web/CSS">CSS</a> <strong><code>:focus-within</code></strong> đại diện cho thành phần nhận focus hoặc <em>chứa </em>một thành phần nhận focus. Nói cách khác, nó đại diện cho một thành phần mà chính nó khớp bởi một lớp giả {{cssxref(":focus")}} hoặc có một hậu duệ (con cháu) được khớp bởi <code>:focus</code>. (Gồm cả hậu duệ trong <a href="/en-US/docs/Web/Web_Components/Shadow_DOM">shadow trees</a>.)</p> + +<pre><code>/* Chọn một <div> khi hậu duệ của nó được focus */</code> +div:focus-within { + background: cyan; +}</pre> + +<p>Nó rất hữu dụng, ví dụ chung, để làm nổi bật toàn bộ container {{htmlElement("form")}} khi người dùng focus vào một trong các field {{htmlElement("input")}} của nó.</p> + +<h2 id="Cú_pháp">Cú pháp</h2> + +<pre class="syntaxbox">{{csssyntax}}</pre> + +<h2 id="Ví_dụ">Ví dụ</h2> + +<p>Trong ví dụ này, form sẽ nhận kiểu màu đặc biệt khi text input nhận focus.</p> + +<h3 id="HTML">HTML</h3> + +<pre class="brush: html"><p>Try typing into this form.</p> + +<form> + <label for="given_name">Given Name:</label> + <input id="given_name" type="text"> + <br> + <label for="family_name">Family Name:</label> + <input id="family_name" type="text"> +</form></pre> + +<h3 id="CSS">CSS</h3> + +<pre class="brush: css">form { + border: 1px solid; + color: gray; + padding: 4px; +} + +form:focus-within { + background: #ff8; + color: black; +} + +input { + margin: 4px; +} +</pre> + +<h3 id="Result">Result</h3> + +<p>{{EmbedLiveSample("Example", 500, 150)}}</p> + +<h2 id="Chi_tiết">Chi tiết</h2> + +<table class="standard-table"> + <thead> + <tr> + <th scope="col">Chi tiết</th> + <th scope="col">Tình trạng</th> + <th scope="col">Comment</th> + </tr> + </thead> + <tbody> + <tr> + <td>{{SpecName("CSS4 Selectors", "#the-focus-within-pseudo", ":focus-within")}}</td> + <td>{{Spec2("CSS4 Selectors")}}</td> + <td>Initial definition.</td> + </tr> + </tbody> +</table> + +<h2 id="Tương_thích_Trình_duyệt">Tương thích Trình duyệt</h2> + + + +<p>{{Compat("css.selectors.focus-within")}}</p> + +<h2 id="Xem_cả">Xem cả</h2> + +<ul> + <li>{{cssxref(":focus")}}</li> +</ul> |
