【发布时间】:2019-06-18 23:44:29
【问题描述】:
我正在尝试在我的 WooCommerce 结帐页面中复制 Shopify 结帐的体验,方法是在用户关注某个输入时为标签设置动画,如下所示:
我尝试过使用 input:focus ~ label,但它不起作用,因为默认的 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: 500;
}
</style>
谢谢!
【问题讨论】:
-
请你分享截图,你的期望是什么?
-
Shopify 没有为此使用 HTML、CSS 和 JS 吗?您能否在您所指的网站上分享记录 Shopify 如何做到这一点的片段?
-
是的,我指的是this effect
-
哦,我的意思是更多地在编程上下文中与您的问题共享这些片段。到目前为止,我有很多问题需要从这个问题中提取出来,这些问题可能与您实际陷入困境的场景相关,这会阻止您自己进行翻译工作。
-
我正在寻找相同的。从我读到的内容来看,问题还在于标签必须在输入之后,所以 WooCommerce 似乎阻止了它的工作。
标签: css wordpress woocommerce