Answer the question
In order to leave comments, you need to log in
How to make the background the height of the screen with scrolling?
Hello. I saw such a feature on some sites: when we go to the site, we have a background image according to the size of the browser. But if you start scrolling, then the image remains in its place and another one or just filling begins. Unfortunately, I can’t recall examples of such sites from memory, since when I found them, there was no such task.
Thank you.
Answer the question
In order to leave comments, you need to log in
CSS property background-attachment: fixed; will make the background image not movable when scrolling, but stretch the background image background-size: contain;
Well, you were rightly told that this is Parallax, it's just that it can be presented in any form. Your task is something like this:
.layer-1 {
background: url(img/img.jpg) center center no-repeat; /*задаем картинку фона по центру и не повторяем её*/
background-size: 100%; /*Растягивает бэкграунд на всю площадь экрана, можно ещё применить св-во cover, но не забудь расставить префиксы*/
background-attachment: fixed; /*фиксируем бэкграунд при прокрутке*/
z-index: -1; /*говорим, что он будет невидим под другими слоями*/
}
.layer-2 /*Наезжающий слой снизу*/ {
background: url(img/img.jpg) center center no-repeat;
background-size: 100%;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question