首页 > 解决方案 > 我无法集中注意力让孩子影响父母

问题描述

我在 HTML 中有这段代码:

<div class="firstname-input">
  <input type="text" id="firstname" name="firstname" placeholder="First name">
  <button onclick="showName()"><figure></figure></button>
</div>

我想添加边框:2px solid #f90; 到.firstname-input,集中输入如果我写这个:

.firstname-input input:focus .firstname-input {
    opacity: .1;
}

这是行不通的。

标签: htmlcsscss-selectors

解决方案


利用

.firstname-input:focus-within {}

并添加您选择的样式


推荐阅读