Skip to content

Commit 7e8025f

Browse files
authored
Issue 350 (#416)
* Change fixed cover background * add pseudo-element to overlay styles
1 parent 1635fee commit 7e8025f

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

src/includes/customizer/class-boldgrid-framework-customizer-background.php

+24-2
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,28 @@ public function create_background_styles() {
275275
'background-repeat: no-repeat;' .
276276
'background-attachment: fixed;' .
277277
'}';
278+
} elseif ( 'fixed' === $bg_attach && 'cover' === $bg_size ) {
279+
// This sets the background to a pseudo element to work with iOS.
280+
$css = 'body.custom-background::before {' .
281+
'content: "";' .
282+
'top: 0;' .
283+
'left: 0;' .
284+
'position: fixed;' .
285+
'background-size: cover;' .
286+
'width: 100%;' .
287+
'height: 100%;' .
288+
'z-index: -1;' .
289+
'background-position: center top;';
290+
if ( $bg_image ) {
291+
$css .= 'background-image: url("' . esc_attr( $bg_image ) . '");';
292+
}
293+
294+
if ( $bg_repeat ) {
295+
$css .= 'background-repeat: ' . esc_attr( $bg_repeat ) . ';';
296+
}
297+
298+
$css .= '}';
299+
278300
} elseif ( 'fixed' === $bg_attach ) {
279301
$css = 'body.custom-background {' .
280302
'background-attachment: fixed;';
@@ -354,8 +376,8 @@ public function create_overlay_css( $image ) {
354376
$color_obj->alpha = $alpha;
355377
$new_color = esc_attr( $color_obj->toCSS( 'rgba' ) );
356378

357-
$rule = "@supports(background-blend-mode: $type) { body.custom-background, body.custom-background > [id^=\"jarallax-container\"] > div { background-color: $new_color !important; background-blend-mode: $type; } }";
358-
$rule .= "@supports not (background-blend-mode: $type) { body.custom-background, body.custom-background > [id^=\"jarallax-container\"] > div { background-color: $color !important; opacity: $alpha; } }";
379+
$rule = "@supports(background-blend-mode: $type) { body.custom-background::before, body.custom-background, body.custom-background > [id^=\"jarallax-container\"] > div { background-color: $new_color !important; background-blend-mode: $type; } }";
380+
$rule .= "@supports not (background-blend-mode: $type) { body.custom-background::before, body.custom-background, body.custom-background > [id^=\"jarallax-container\"] > div { background-color: $color !important; opacity: $alpha; } }";
359381
}
360382

361383
return $rule;

0 commit comments

Comments
 (0)