My Fixed Background Made Scrolling the Site Very Slow, What How to Do to Improve It

My fixed background made scrolling the site very slow, what can I do to improve it?

The problem goes away for me when I remove the background-size property. I think it was the scaling of the large image that was causing the problem. If that doesn't work, just remove the background image altogether. However, I've never heard of a large background image causing lag before.

background-attachment fixed chrome lag

Just add-

transform:translatez(0);
-webkit-transform:translatez(0);

How to make the scroll speed of background image of the webpage slower

Here's a very simple example of a parallax effect using jQuery:

$(document).scroll(function() {

var scroll = $(window).scrollTop();

$("img").css("top", "0" + (scroll / 1.8) + "px");

});
body {

margin: 0;

}

img {

position: absolute;

top: 0;

z-index: -1;

}

.block {

background: #ffffff;

position: relative;

margin-top: 100px;

height: 1000px;

}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

<div class="wrap">

<img src="https://placeimg.com/640/480/any">

<div class="block">Some text</div>

</div>

(CSS) Make a background image scroll slower than everything else

I stumbled upon this looking for more flexibility in my parallax speed that I have created with pure CSS and I just want to point out that all these people are wrong and it is possible with pure CSS It is also possible to control the height of your element better.

You will probably have to edit your DOM/HTML a bit to have some container elements, in your case you are applying the background to the body which will restrict you a lot and doesn't seem like a good idea.

http://keithclark.co.uk/articles/pure-css-parallax-websites/

Here is how you control the height with Viewport-percentage lenghts based on screen size:

https://stanhub.com/how-to-make-div-element-100-height-of-browser-window-using-css-only/

  .forefront-element {
-webkit-transform: translateZ(999px) scale(.7);
transform: translateZ(999px) scale(.7);
z-index: 1;
}

.base-element {
-webkit-transform: translateZ(0);
transform: translateZ(0);
z-index: 4;
}

.background-element {
-webkit-transform: translateZ(-999px) scale(2);
transform: translateZ(-999px) scale(2);
z-index: 3;
}

Layer speed is controlled by a combination of the perspective and the Z translation values. Elements with negative Z values will scroll slower than those with a positive value. The further the value is from 0 the more pronounced the parallax effect (i.e. translateZ(-10px) will scroll slower than translateZ(-1px)).

Here is a demo I found with a google search because I know there are a lot of non-believers out there, never say impossible:

http://keithclark.co.uk/articles/pure-css-parallax-websites/demo3/



Related Topics



Leave a reply



Submit