Fix Full-Height Sections on Mobile Browsers
Makes Cover blocks and sections set to 100vh fit the visible screen on phones, where the browser's address bar otherwise hides the bottom of the section and its buttons.
Opens WPIDE on
Code
@supports (height: 100svh) {
.wp-block-cover[style*="min-height:100vh"],
.wp-block-cover[style*="min-height: 100vh"],
.wp-block-group[style*="min-height:100vh"],
.wp-block-group[style*="min-height: 100vh"] {
min-height: 100svh !important;
}
.admin-bar .wp-block-cover[style*="min-height:100vh"],
.admin-bar .wp-block-cover[style*="min-height: 100vh"] {
min-height: calc(100svh - var(--wp-admin--admin-bar--height, 0px)) !important;
}
}
Notes
Uses the small-viewport unit (svh), supported by all current browsers; older ones keep the original height.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.