[CSS] Conditionally Assign Style to a Parent Element with Focus-Within Pseudo-class
CSS to with Class Element Style Parent focus
2023-09-14 08:59:14 时间
Use the focus-within pseudo-class to conditionally assign styling to a parent element when its child receives focus.
HTML:
import "./styles.css"; document.getElementById("app").innerHTML = ` <ul id="red"> <li> <input value="Red"> </li> </ul> `;
CSS:
#red:focus-within { background-color: red; }
相关文章
- css流程图、步骤图,流程线与环节分别实现,支持单环节、多环节情况。scss生成CSS
- 前端每日实战:134# 视频演示如何用 CSS 和 GSAP 创作一个树枝发芽的 loader
- CSS垂直居中和水平居中
- css - 使用 " dl、dt、dd " 描述列表的形式 , 实现 【图片加下方文字】 的快速布局
- [systemd]How To Use Systemctl to Manage Systemd Services and Units
- [CSS] Use CSS Variables Almost like Boolean Values with Calc (maintainable css)
- css 去除浮动布局
- [css]演示:纯CSS实现的右侧底部简洁悬浮效果
- 关于Yii2中CSS,JS文件的引入心得
- [CSS] Using inline-grid to gain easy control over gap and size
- [CSS 3] Apply Aspect Ratio Sizing to Images with CSS object-fit
- [CSS] Use CSS Variables with Calc and HSL to Implement Dark Mode
- [CSS 3] Use Multiple Background Images to Create Single Element CSS Art
- [CSS] Use CSS pseudo-elements and mix-blend-mode to Create a Duotone Style Effect
- [CSS 3] Use the Border-Radius CSS Property to Define Horizontal and Vertical Radius
- [CSS3] Make a One-time CSS Animation that Does Not Revert to its Original Style
- [CSS3] Identify Interactive HTML Elements with CSS Link Pseudo Classes
- [CSS] Use CSS Counters to Create Pure CSS Dynamic Lists
- [CSS3] Create a fixed-fluid-fixed layout using CSS calc()
- Atitit.css 规范 bem 项目中 CSS 的组织和管理
- Atitit.css 规范 bem 项目中 CSS 的组织和管理
- Atitit.css 规范 bem 项目中 CSS 的组织和管理
- css 适配
- 高性能Web动画和渲染原理系列(1)——CSS动画和JS动画
- CSS_使用css布局
- PAT 1033. To Fill or Not to Fill (贪心)
- 【CSS】css弹性布局、CSS hack_08