admin管理员组文章数量:1122846
I just upgraded a project to WordPress 6.0.1, and now have load of wp-container-*
inline styles injected which are breaking my site:
<style>.wp-container-2 {display: flex;gap: 0.5em;flex-wrap: wrap;align-items: center;}.wp-container-2 > * { margin: 0; }</style>
<style>.wp-container-3 {display: flex;gap: 0.5em;flex-wrap: wrap;align-items: center;justify-content: center;}.wp-container-3 > * { margin: 0; }</style>
<style>.wp-container-5 {display: flex;gap: 0.5em;flex-wrap: wrap;align-items: center;}.wp-container-5 > * { margin: 0; }</style>
<style>.wp-container-6 {display: flex;gap: 0.5em;flex-wrap: wrap;align-items: center;justify-content: center;}.wp-container-6 > * { margin: 0; }</style>
<style>.wp-container-8 {display: flex;gap: 0.5em;flex-wrap: wrap;align-items: center;}.wp-container-8 > * { margin: 0; }</style>
<style>.wp-container-9 {display: flex;gap: 0.5em;flex-wrap: wrap;align-items: center;justify-content: center;}.wp-container-9 > * { margin: 0; }</style>
<style>.wp-container-11 {display: flex;gap: 0.5em;flex-wrap: wrap;align-items: center;}.wp-container-11 > * { margin: 0; }</style>
<style>.wp-container-12 {display: flex;gap: 0.5em;flex-wrap: wrap;align-items: center;justify-content: center;}.wp-container-12 > * { margin: 0; }</style>
In addition there are also styles overriding my styling for Gallery blocks - for example:
<style> .wp-block-gallery-4{ --wp--style--unstable-gallery-gap: var( --wp--style--gallery-gap-default, var( --gallery-block--gutter-size, var( --wp--style--block-gap, 0.5em ) ) ); gap: var( --wp--style--gallery-gap-default, var( --gallery-block--gutter-size, var( --wp--style--block-gap, 0.5em ) ) )}</style>
This is overriding my Tailwind CSS and I can't see where they are coming from.
Anyone encountered / solved this?
I just upgraded a project to WordPress 6.0.1, and now have load of wp-container-*
inline styles injected which are breaking my site:
<style>.wp-container-2 {display: flex;gap: 0.5em;flex-wrap: wrap;align-items: center;}.wp-container-2 > * { margin: 0; }</style>
<style>.wp-container-3 {display: flex;gap: 0.5em;flex-wrap: wrap;align-items: center;justify-content: center;}.wp-container-3 > * { margin: 0; }</style>
<style>.wp-container-5 {display: flex;gap: 0.5em;flex-wrap: wrap;align-items: center;}.wp-container-5 > * { margin: 0; }</style>
<style>.wp-container-6 {display: flex;gap: 0.5em;flex-wrap: wrap;align-items: center;justify-content: center;}.wp-container-6 > * { margin: 0; }</style>
<style>.wp-container-8 {display: flex;gap: 0.5em;flex-wrap: wrap;align-items: center;}.wp-container-8 > * { margin: 0; }</style>
<style>.wp-container-9 {display: flex;gap: 0.5em;flex-wrap: wrap;align-items: center;justify-content: center;}.wp-container-9 > * { margin: 0; }</style>
<style>.wp-container-11 {display: flex;gap: 0.5em;flex-wrap: wrap;align-items: center;}.wp-container-11 > * { margin: 0; }</style>
<style>.wp-container-12 {display: flex;gap: 0.5em;flex-wrap: wrap;align-items: center;justify-content: center;}.wp-container-12 > * { margin: 0; }</style>
In addition there are also styles overriding my styling for Gallery blocks - for example:
<style> .wp-block-gallery-4{ --wp--style--unstable-gallery-gap: var( --wp--style--gallery-gap-default, var( --gallery-block--gutter-size, var( --wp--style--block-gap, 0.5em ) ) ); gap: var( --wp--style--gallery-gap-default, var( --gallery-block--gutter-size, var( --wp--style--block-gap, 0.5em ) ) )}</style>
This is overriding my Tailwind CSS and I can't see where they are coming from.
Anyone encountered / solved this?
Share Improve this question edited Jul 14, 2022 at 11:00 fuxia♦ 107k38 gold badges255 silver badges459 bronze badges asked Jul 13, 2022 at 16:05 codewithfeelingcodewithfeeling 4764 silver badges6 bronze badges 5 |1 Answer
Reset to default 0These styles are styles applied through the block settings toolbar.
This code will remove the wp-container-id class for every block:
remove_filter( 'render_block', 'wp_render_layout_support_flag', 10, 2 );
This was found on this page. It has more advice on removing block styles and altering them as well.
Also found on the above page was this code to remove all block styles on the front. It might help the second part of your question I missed.
function prefix_remove_core_block_styles() {
global $wp_styles;
foreach ( $wp_styles->queue as $key => $handle ) {
if ( strpos( $handle, 'wp-block-' ) === 0 ) {
wp_dequeue_style( $handle );
}
}
}
add_action( 'wp_enqueue_scripts', 'prefix_remove_core_block_styles' );
本文标签: cssWordPress 6inline container styles breaking my site
版权声明:本文标题:css - WordPress 6 - inline container styles breaking my site 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736294142a1929294.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
theme.json
to configure or remove those controls? Is your theme a block theme? Classic? Hybrid? – Tom J Nowell ♦ Commented Jul 13, 2022 at 16:54theme.json
file but the settings aren't getting rid of the offending inline styles (eg."settings": {"spacing": {"blockGap" : null} } } has no effect. The
wp-block-gallery-*` styles which are causing issues don't seem to be available as settings in thetheme.json
file. – codewithfeeling Commented Jul 13, 2022 at 18:02margin
padding
andunits
– Tom J Nowell ♦ Commented Jul 13, 2022 at 18:22