-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Closed
Labels
CSS StylingRelated to editor and front end styles, CSS-specific issues.Related to editor and front end styles, CSS-specific issues.[Block] CoverAffects the Cover Block - used to display content laid over a background imageAffects the Cover Block - used to display content laid over a background image
Description
The current Cover Block has a setting through which the user can choose a minimum height for the Block. The standard is 430px. However, this minimum height applies across all screen sizes.
An alternative solution which we use in our projects is to allow the Cover Block to receive an aspect ratio, by way of a custom control and custom class names on the container DIV
. With this setting, the user can choose an aspect ratio of (say) 2:1, which will ensure that the block remains consistently proportioned across all screen sizes.
Our CSS is as follows. (The standard feature using min-height still applies, but only if the min-height is set explicitly in the Editor by way of dragging the height, or by adding a value to the min-height input field.)
.wp-block-cover {
&[class*='is-style-aspect'] {
min-height: 0;
}
&.is-style-aspect-21::after {
content: '';
display: block;
padding-bottom: percentage(1/2);
}
&.is-style-aspect-31::after {
content: '';
display: block;
padding-bottom: percentage(1/3);
}
&.is-style-aspect-41::after {
content: '';
display: block;
padding-bottom: percentage(1/4);
}
&.is-style-aspect-169::after {
content: '';
display: block;
padding-bottom: percentage(9/16);
}
&.is-style-full-height::after {
content: '';
display: block;
padding-bottom: 100vh;
}
}
KZeni
Metadata
Metadata
Assignees
Labels
CSS StylingRelated to editor and front end styles, CSS-specific issues.Related to editor and front end styles, CSS-specific issues.[Block] CoverAffects the Cover Block - used to display content laid over a background imageAffects the Cover Block - used to display content laid over a background image