在Woocommerce帐单邮寄地址字段中更改字段宽度

时间:2019-11-10 21:29:18

标签: php wordpress woocommerce

我有一个使用子主题的WordPress网站,我在其中安装了WooCommerce,但是帐单/运输表格看起来很奇怪,没有对齐,并且大多数字段很小。国家字段(例如)如下所示:

Woocommerce billing address

我试图通过使用functions.php中的一个函数来更改字段类以使其变大,但它似乎不起作用。这就是我用的:

function em_align_address_checkout_fields( $fields ) {
   $fields['billing_country']['class'][] = 'form-row-wide';

   return $fields;
}
add_filter( 'woocommerce_billing_fields', 'em_align_address_checkout_fields' );

是否可以更改字段的宽度?而且,如果您知道如何解决整体样式,我将不胜感激,与其他文章相比,我不认为这是看起来的样子,而且我不是Woocommerce或Wordpress的专家。

感谢您的帮助!

1 个答案:

答案 0 :(得分:0)

您可以在子主题css中为这些字段编写自定义css。

    .woocommerce-billing-fields__field-wrapper label{ width 50%;float:left;}/* Use this only if necessary.It may affect overall checkout fields layout */
    #billing_country_field label{ width:50%;}
    #billing_country_field select{ width:50%;}

或者您可以使用官方扩展名来覆盖结帐布局。

https://docs.woocommerce.com/document/checkout-field-editor/