Wordpress Admin Thickbox: Remove Margins/Padding

I've added a Thickbox to an admin page by adding the the following action hook to add the library code

add_action( 'in_admin_footer', function(){   
    add_thickbox();    
});

And then triggering an inline thick box manually via some javascript code

tb_show(null,'#TB_inline?height=300width=300inlineId=id_of_div_with_my_thickbox',false);

When I do this, the thickbox has some margins/padding on the left and right (see in screenshot below how everything is centered)

I'd like to

  1. Remove these styles for everything is flush against the Thickbox (as a style reset)
  2. But only for my Thickbox.

Re: #2 -- This is something for a plugin that's going to be on many admin backend pages. I know I can target the id=TB_ajaxContent div to change the style -- but this runs the risk of breaking other Thickboxes added to the system

Is there known science for this in the Wordpress community? Or am I on my own as a plugin developer to create this functionality myself?

Topic thickbox css admin Wordpress javascript

Category Web


You can use this for a custom stylesheet. Copy and paste all the CSS from the original thickbox.css in your custom stylesheet.

Now you can edit your custom CSS and add the code below in your plugin.

function get_thickbox() {
    // Add the original thickbox
    add_thickbox();

    // register your custom stylesheet
    // Make sure its in your speciefied folder!
    wp_register_style( 'thickbox_css', plugins_url( 'pluginname/stylesheet.css' ) );

    // enqueue our new stylesheet
    enqueue_style( 'thickbox_css' );
}
add_action('wp_enqueue_scripts', 'get_thickbox');

// Thats it!
// You can now reach your customized thickbox by:
get_thickbox();

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.