0

i have added two fields in my magento 2 checkout at shipping address tab. My fields are check boxes and and i want to add some css to those check boxes therefore i have added custom css file but as i observer css gets applied after the page load. Magento checkout is totally based on knockout js and other dependencies that why my css is not getting applied. i have added a hook.js and that js file is getting applied. i have also tried to add Css using jQuery.

 $("[name='shippingAddress.custom_attributes.displaynewsfeed']").css("padding-left","20%");
 $("[name='shippingAddress.custom_attributes.displayreceipt']").css("padding-left","20%");

But this is not getting applied so i have tried another method in jQuery which delayed the function for 2 seconds its working but its not acceptable. Is there any solution where i can add CSS withing the form load not after some seconds or before Form load.

Small Help will be Greatly Appreciated. Thanks in Advanced :)

asked Mar 19, 2020 at 5:44
3

1 Answer 1

0

Why didn't you use css for this? (add to your theme):

input[name='shippingAddress.custom_attributes.displaynewsfeed'] { padding-left:20% }

input[name='shippingAddress.custom_attributes.displayreceipt'] { padding-left:20% }

answered Mar 19, 2020 at 6:05
1
  • If i add custom css to my theme's css files will it solve my problem. And will that css will apply all the magento 2 checkout fields load via knocoutn js and ajax Commented Mar 19, 2020 at 6:11

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.