gpt4 book ai didi

html - css 在元素和 :focus 之前

转载 作者:太空宇宙 更新时间:2023-11-04 10:09:33 26 4
gpt4 key购买 nike

我必须在点击输入后更改背景颜色并在 <p> 之前元素。只有 input 并不难,但是<p>是的。

代码

    input[type="text"]:focus ~ .prefix{
background-color:#e4ff00 !important;
}

input[type="text"]:focus + .prefix{
background-color:#e4ff00 !important;
}
<div class="inputholder holder50">
<p class="prefix">NIP</p>
<input type="text" value="" name="nip">
</div>

但是没用

最佳答案

如果你在 donwards 中使用 p 它会起作用

<div class="inputholder holder50">
<input type="text" value="" name="nip">
<p class="prefix">NIP</p>
</div>

<style>
input[type="text"]:focus ~ .prefix{
background-color:#e4ff00 !important;
}

input[type="text"]:focus + .prefix{
background-color:#e4ff00 !important;
}
</style>

关于html - css 在元素和 :focus 之前,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37724213/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com