Chrome experiencing conflicts with backstretch when using multiple background images

In order to dynamically apply fullscreen background images in a WordPress site, I am utilizing Backstretch.js along with a custom field.

Everything is functioning properly for the body's background image. However, there seems to be an issue with another element on the page that has its background image set through CSS. This problem only occurs in Chrome.

Upon loading the page, both background images are displayed correctly. But as I scroll down, the CSS background disappears - sometimes entirely, and sometimes just sections of it vanish. Removing Backstretch resolves this issue, but ideally, I would like both backgrounds to remain fixed.

BACKSTRETCH

<?php $image = get_post_meta($post->ID, 'wpcf-background-image', TRUE); ?>
    <?php if ( ! empty ( $image ) ) { ?>
        <script>
            jQuery.backstretch("<?php echo $image ?>");
        </script>
<?php } ?>

CSS

.full-grey-cover {
overflow: hidden;
background-image: url(images/menu-bg-2.jpg) !important;
background-repeat: no-repeat !important; 
background-size: cover !important;
background-position: center !important;
background-attachment: fixed !important;
-webkit-background-size: cover !important;
-moz-background-size: cover !important;
-o-background-size: cover !important;
background-size: cover !important;

}

I currently have two pages set up using Backstretch for the background.

and

These pages seem to function properly in Firefox and Safari, but not in Chrome (Mac/Mavericks). This inconvenience arose because I needed to use Backstretch since the fixed background was not working well on IOS devices.

N.

Answer №1

Following the recent Chrome update (38.0.2125.101 m), I faced a similar issue with backstretch. Upon investigation, I discovered that the culprit was the negative z-index value assigned to the .backstretch class, causing disruption on my website. To resolve this, I adjusted the z-index to 1 and modified my wrapper class to position:relative with z-index:2, successfully restoring normal functionality. I hope this solution proves helpful!

Answer №2

This fix worked perfectly for my issue.

To implement this solution, make sure to insert the following code snippet into Backstretch.js:

$('body').wrapInner('<div id="backstreach-fix" style="z-index: 1; position: relative;">');

Place this code inside a.fn.backstretch right after:

0 === a(d).scrollTop() && d.scrollTo(0, 0);

Additionally, I had to adjust the zIndex values within the file.

Locate zIndex:-999998 and update it to zIndex:1

Search for zIndex:-999999 and switch it to zIndex:0

Answer №3

On a single page website (), I encountered the same issue as Neil Day. I utilized Backstretch in two different ways. Initially, I synchronized the background image with an animated slider created using Sweeper and animate.less CSS library. Secondly, I synchronized the background change with scrolling to various sections of the one-page site.

Everything was functioning correctly until Chrome underwent an update. Following this update, Backstretch started malfunctioning.

I attempted the solution provided by Janusz Chodzicki (avoiding negative z-index) with some modifications (I forked the original Github project: https://github.com/magicbruno/jquery-backstretch), but this only resolved the initial issue.

During page scrolling, I experienced unusual behavior. The fixed background would scroll, yet the Backstretch image either didn't appear at all or would briefly show up partially cropped, etc...

Ultimately, I decided to remove the CSS rule "-webkit-backface-visibility: hidden," which animate.less attaches to the body, and now everything is back to normal post-Chrome update (even without the negative z-index correction).

Hopefully, this information proves helpful to others.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Creating dynamic JSON endpoints using JSP with Spring MVC

When working with JSON in my webapp, I have successfully passed a variable wordId to the Spring-mvc Controller using a static URL. However, I am unsure of the best practice for dealing with dynamic or parametric URLs. Controller Section: @RequestMapping( ...

Having trouble getting the hover effect to work when selecting a different section of the SVG

In my SVG checkbox design, I have a circle element surrounding a polyline element (which acts as the checkmark). The boundaries of the icon extend beyond the circle, causing hover styles to trigger even when hovering outside the circle. I want to change st ...

The presence of onChange?: (ValueType, ActionMeta) => void with OptionType is not compatible

After updating to version v2.4.2, I keep encountering an error from flow regarding react-select. It seems that I am passing the correct types to the handle change, which expects an array with objects + OptionType accepting any string [string]: any. Can som ...

Tips for changing array items into an object using JavaScript

I am working with a list of arrays. let arr = ["one","two"] This is the code I am currently using: arr.map(item=>{ item }) I am trying to transform the array into an array of sub-arrays [ { "one": [{ ...

AngularJS Expression Manipulation

I am looking to implement a functionality similar to the one below: HTML <mydir> {{config = {type: 'X', options: 'y'}} </mydir> <mydir> {{config = {type: 'a', options: 'b'}} </mydir> JS Dir ...

The functionality of the button is disabled once a pop-up JavaScript is implemented

I have encountered an issue with my HTML code that involves a button intended to hide certain content. The problem arose when I implemented a popup feature, causing the button to malfunction. Here is the JavaScript for the popup: $ = function(id) { retur ...

Failure to submit form in Bootstrap modal

Can someone please help me troubleshoot why the form in the Bootstrap modal is not submitting? This is the HTML code for the modal (sidebar.php) <!-- Beginning of Joel's modal --> <div class="modal fade" id="myModal" tabindex="-1" role="dia ...

Suggestions for incrementing a button's ID every time it is clicked

I am working on a button functionality that increases the button id when clicked. Below is the HTML code for the button: <input type="button" id="repeataddon-1" name="repeataddon" class="repeataddon" value="add" > Accompanied by the following scr ...

Troubleshooting z-index conflict when using :before pseudo element to emphasize list entries

I am experiencing an issue with highlighting items in a list generated by JSTree using the :before pseudo element. The z-indexes seem to be causing some trouble, as adjusting them results in the highlighting appearing either behind all links or in front of ...

Creating a fixed footer within a div that is absolutely positioned using CSS

I am looking to implement a sticky footer within an absolutely positioned div element. My initial approach was to position the footer div absolutely as well - within an additional relatively positioned "page" div (which would contain the main content of t ...

What methods can I use to prevent caching of XMLHttpRequest requests without relying on jQuery?

I am currently working on a web application that refreshes a table every minute from an XML file. However, I have noticed that when I make edits to the content of the XML file, I see a "304 Not Modified" message in the script log when trying to retrieve th ...

Which is better: using multiple makeStyles or just one in Material UI?

Uncertain about the best approach in this situation. Is it acceptable to generate styles using makeStyles for each component individually, or would it be better to create one in the base component and simply pass down class names? ...

QuickFit, the jQuery plugin, automatically adjusts the size of text that is too large

I have incorporated the QuickFit library into my website to automatically resize text. However, I am running into an issue where the text is exceeding the boundaries of its containing div with a fixed size. This is something I need to rectify. This is ho ...

Using JQuery to enable the movement of divs on a screen through clicking and dragging, without the use of

Recently, I've been experimenting with a small project involving draggable divs. However, the code I've written doesn't seem to be functioning properly, causing JQuery to become unresponsive. Is there an alternative method that is simple an ...

Is it possible to trigger the onNewRequest property when the onBlur event is fired for AutoComplete in Material-UI?

Currently, I am utilizing Material-UI and making use of the onNewRequest property in the AutoComplete field. However, the onNewRequest only triggers when Enter is pressed or when a value is selected. I am interested in calling the onNewRequest even when ...

"Placing an image at the bottom within a DIV container in HTML

My goal is to neatly align a group of images at the bottom of a fixed-height div. The images all have the same height and width, making the alignment easier. Here is the current structure of my code: <div id="randomContainer"> <div id="image ...

Position the text on the left side while also centering it within my div

I am attempting to center align some links within my div, while also ensuring that the text of the links is aligned to the left. However, I have been unsuccessful in achieving this. I can either align them to the left or center, but not both simultaneousl ...

Discover the steps to showcase a specific option from a select list at the top row through VueJs

Below is the code to iterate through the elements of teamLeaderOfWithDescendants <option :value="item.user_id" v-for="item in teamLeaderOfWithDescendants"> {{item.user_full_name}} </option> Is there a way to prioritize the row where item.u ...

Choosing a personalized component using document selector

Currently, I am working on an application using Stenciljs and have created a custom element like this: <custom-alert alertType="warning" alertId="warningMessage" hide>Be warned</custom-alert> The challenge arises when attem ...

VueJS - Validating Props with Objects

What is the best way to validate Object type props in VueJS to guarantee that certain fields are defined within the object? For instance, I need to make sure that the user prop includes 'name', 'birthDate', and other specific fields. ...