我完全不知道如何使用更高级的 css 选择器,例如 + 或 >但是由于我现在需要它来防止过多的 JS,也许有人可以帮助我解决这个块的这种特殊情况:
I am not at all getting how to use more advanced css-selectors like + or > But as I am now needing it to prevent too much JS, maybe someone can help me out with this particular situation of this block:
<section class="rf_re1-suche_container">
<input type="search" placeholder="Your search">
<button>Send</button>
</section>
我想这样做:
.rf_re1-suche_container input:focus{
background:orange;
}
但也适用于按钮.所以:如果输入有焦点,我希望输入和按钮具有相同的背景.我该怎么做?谢谢!
but also for the button. So: If the input has a focus I want the input AND the button to have the same background. How would I do that? Thanks!
您需要分别定位输入和按钮.因为您希望这仅在输入具有焦点时应用,所以您需要重复整个选择器,包括 input:focus 部分,然后使用 + 组合器链接焦点输入的按钮:
You will need to target the input and the button separately. Because you want this to apply only when the input has focus, you will need to repeat the entire selector including the input:focus portion, then use a + combinator to link the button to the focused input:
.rf_re1-suche_container input:focus,
.rf_re1-suche_container input:focus + button {
background: orange;
}
<section class="rf_re1-suche_container">
<input type="search" placeholder="Your search">
<button>Send</button>
</section>
这篇关于多个元素的 CSS 选择器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
在javascript中保护随机数?Secure random numbers in javascript?(在javascript中保护随机数?)
img src 链接中的授权标头Authorization header in img src link(img src 链接中的授权标头)
通过 Javascript 发送 Authorization Token BearerSending Authorization Token Bearer through Javascript(通过 Javascript 发送 Authorization Token Bearer)
我必须将令牌存储在 cookie 或本地存储或会话中吗Do I have to store tokens in cookies or localstorage or session?(我必须将令牌存储在 cookie 或本地存储或会话中吗?)
如何在不使用库的情况下在 javascript 中解码 jwtHow to decode jwt token in javascript without using a library?(如何在不使用库的情况下在 javascript 中解码 jwt 令牌?)
:hover:before text-decoration none 没有效果?:hover:before text-decoration none has no effects?(:hover:before text-decoration none 没有效果?)