Hello,
Thanks for the feedback!
Unfortunately it is not possible to enqueue/dequeue stylesheets for specific parts of an HTML page.
Stylesheets are always applied to the whole page, and since Dynamic Preview is rendered directly in the page, any HTML elements from your Layout PHP will inherit from the page stylesheets.
You could try dequeue WP / ACFE CSS files in the admin, but you’ll end-up with broken Admin UI, since these files contain CSS rules for the page.
For example, any element with the class .card
will inherit css properties from /wp-admin/css/forms.css
:
.card {
position: relative;
margin-top: 20px;
padding: 0.7em 2em 1em;
min-width: 255px;
max-width: 520px;
border: 1px solid #c3c4c7;
box-shadow: 0 1px 1px rgba(0, 0, 0, 0.04);
background: #fff;
box-sizing: border-box;
}
To avoid that issue you could add some CSS reset rules for your layouts. But that would require to chase each potential CSS rules added by WP.
The other solution would be to make sure that you prefix all your elements class with a unique namespace, for example .sababaa-card
.
For the <h2>
element, unfortunately WordPress add some strong rule, using an id in /wp-admin/css/edit.css
:
#poststuff h3.hndle, #poststuff .stuffbox > h3, #poststuff h2 {
font-size: 14px;
padding: 8px 12px;
margin: 0;
line-height: 1.4;
}
So you’ll have to either reset it using an !important
declaration, or use your own id, or the id defined by ACF in the metabox: <div id="acf-group_63ca7cb29e9d0" class="postbox acf-postbox">
to overwrite the rule. Example:
-.preview h2{
font-size: 18px !important;
// reset h2 in preview
}
// or:
#acf-group_63ca7cb29e9d0 -.preview h2{
font-size: 18px;
// reset h2 in preview
}
Hope it helps!
Have a nice day!
Regards.