How to style custom meta boxes with cmb2?

Hi!

I am fairly new to wordpress and I am using custom meta boxes. I really like the cmb2 plugin to help with creating custom meta boxes but I am wondering how to layout the fields in my meta boxes since I don't want them to be put in a straight list.

Since the generated output has lots of css classes attached I reckon that I am supposed to override the css as my needs dictate. That would be fine if I knew where to put my css. I don't suppose I should edit cmb2.css directly.

Can someone please explain to me what is the preferred way to add my css so that it is picked up in my custom meta boxes?

Regards,
Dirk.
dirkil2Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Alicia St RoseOwner & Principle Developer/DesignerCommented:
Hi Dirk,
Can you provide a link to the plugin you are using?
0
dirkil2Author Commented:
Sure, I can. I must have forgotten this in the first place.

CMB2 Plugin
0
Alicia St RoseOwner & Principle Developer/DesignerCommented:
This thread shows you how to place styles in the admin head, which should override the plugin stylesheet:


https://wordpress.org/support/topic/how-do-i-add-css-to-admin-backend-to-displaynone-specific-menu-items
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Fundamentals of JavaScript

Learn the fundamentals of the popular programming language JavaScript so that you can explore the realm of web development.

dirkil2Author Commented:
Perfect! Is there also a way how to link in a css file instead of single css lines? The problem is where to put that css file and how to get the path correct in the <link> statement.
0
Alicia St RoseOwner & Principle Developer/DesignerCommented:
The plugin's css is already added to the head when the plugin is activated. If you want to override the styles you'll need to add styles in the head with the code as demonstrated in my answer.

Otherwise, you will have to dequeue the plugin styles and enqueue your own stylesheet. You will conditionally target the admin with "if(is_admin)".
0
dirkil2Author Commented:
Thank you very mch for your help.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
WordPress

From novice to tech pro — start learning today.