简体   繁体   English

更改 Woocommerce 帐单地址字段中的字段宽度

[英]Change field width in Woocommerce billing address field

I have a WordPress site using a child theme, where I installed WooCommerce, but the billing/shipping forms just look weird, unaligned, and most of the fields are pretty small.我有一个使用子主题的 WordPress 站点,我在其中安装了 WooCommerce,但是帐单/运输 forms 看起来很奇怪,未对齐,并且大多数字段都很小。 The country field (for example) looks like this:国家/地区字段(例如)如下所示:

Woocommerce 帐单地址

I tried to change the field class to make it larger, by using a function in the functions.php, but it does not seem to work.我试图通过在函数中使用 function 来更改字段 class 以使其更大,但它似乎不起作用。 This is what I used:这是我使用的:

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' );

Is there a way to change the width on the fields?有没有办法改变字段的宽度? and if you know how to solve the overall style, I would appreciate, I don't believe this is how it's supposed to look compared to other articles, and I'm not an expert on Woocommerce or Wordpress.如果您知道如何解决整体风格,我将不胜感激,与其他文章相比,我不认为这是它应该看起来的样子,而且我不是 Woocommerce 或 Wordpress 方面的专家。

Thanks for the help!谢谢您的帮助!

You can write custom css for those fields in the child theme css.您可以为子主题 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%;}

Or you can use official extension for overriding checkout layout.或者您可以使用官方扩展来覆盖结帐布局。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM