Hm… didn’t think of multiple pages. Sorry.
I managed somehow to use this workaround within the header (just with “bars” instead of “sections”) so it only has to be done once, but that means you have to change the background color of all .x-section to transparent at the global css.
.x-section {
background-color: transparent;
}
Not sure if that’s practical.
On the other hand, setting the body to 100vh as in your css code is also not so good, especially on mobile, because at first the URL input bar is visible but not calculated into the viewport height and when you start scrolling the content may jump. You could use height: 100dvh;
(dynamic viewport height) or height: 100svh;
(smallest viewport height). But these are not supported by all browsers and didn’t work on my iPhone. So adding another a fallback may be helpfulheight: 100%;
.
I think it’s easier to use the themes Global options and set the background color to transparent and set a background image for the whole site at “Layout and Design” (this adds a JS to the site which “injects” a DIV with the class “backstretch” which contains the image). Then you add some media query to manipulate that DIV. So the css at global css should be like this:
@media screen and (max-width: 480px) {
.backstretch img {
display: none !important;
}
.backstretch:before {
background-image: url("your-mobile-background-image");
background-size: cover;
background-position: center;
display: inline-block !important;
width: 100%; /* or fixed pixel values */
height: 100%; /* or fixed pixel values */
content: "";
}
to replace the background image for mobile devices.
I tested it on my iPhone and the background is not scrolling. But the image may “jump-scale” once you scroll down or up, because the viewport is changing (URL bar of your mobile browser goes away, once you scroll down and comes back when you scroll up). If you use px
instead of percentage or viewport units (px values a bit wider and higher than the mobile screen) you can avoid the “jumps”.