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?
 
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
 
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
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

 
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.