Hello @robswebdev,
The problem is that the WordPress administration already have many CSS rules for various elements (including fonts, text, titles…). For example, the following rule is applied to all h2 & h3 in the admin:
h2, h3 {
color: #23282d;
font-size: 1.3em;
margin: 1em 0;
}
To avoid this behavior, you can enqueue a specific CSS file to reset the CSS inside your template (targetting a specific CSS class).
In your layout template, if the main container <div>
has the class .is-preview
, then you can enqueue a CSS file that reset everything inside .is-preview
. You can read more about CSS reset here and here.
To learn how to add is-preview
class to your template, please read the following tutorial (you’ll also find a CSS style example that target .is-preview
class).
To enqueue a specific CSS file on the administration/preview mode, use the following hook:
// add_action('acfe/flexible/enqueue/name=my_flexible', 'acf_flexible_enqueue', 10, 2);
// add_action('acfe/flexible/enqueue/key=field_xxxxxx', 'acf_flexible_enqueue', 10, 2);
add_action('acfe/flexible/enqueue', 'acf_flexible_enqueue', 10, 2);
function acf_flexible_enqueue($field, $is_preview){
// Only in Ajax preview
if($is_preview){
wp_enqueue_style('my-style-preview', 'https://www.example.com/style-preview.css');
}
}
Hope it helps!
Have a nice day ??
Regards.