首页 > Web开发 > 详细

[CSS] Conditionally Assign Style to a Parent Element with Focus-Within Pseudo-class

时间:2019-08-29 17:27:30      阅读:83      评论:0      收藏:0      [点我收藏+]

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] Conditionally Assign Style to a Parent Element with Focus-Within Pseudo-class

原文:https://www.cnblogs.com/Answer1215/p/11430852.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!