我试图通过在用户关注某个输入时为标签设置动画来复制我的 WooCommerce 结账页面中 Shopify 结账的体验,就像这样:

我试过使用 input:focus ~ 标签,但它不起作用,因为默认的 WooCommerce 输入是在一个跨度 (.woocommerce-input-wrapper) 内,如下所示:
<!-- The basic markup for each input -->
<p class="form-row form-row-first validate-required" id="billing_first_name_field" data-priority="10">
<label for="billing_first_name" class="">Nombre <abbr class="required" title="obligatorio">*</abbr></label>
<span class="woocommerce-input-wrapper">
<input type="text" class="input-text " name="billing_first_name" id="billing_first_name" placeholder="" value="" autocomplete="given-name">
</span>
</p>
<!-- CSS -->
<style>
.woocommerce-billing-fields__field-wrapper .form-row{
position: relative;
}
.woocommerce-billing-fields__field-wrapper .form-row label{
position: absolute;
top: 11px;
left: 11px;
padding: 0;
color: #808080;
transition: .35s;
}
.woocommerce-billing-fields__field-wrapper .form-row input:focus ~ label{
top: -8px;
font-size: 12px;
font-weight: …Run Code Online (Sandbox Code Playgroud)