Last active
August 29, 2015 14:10
-
-
Save gearmobile/5b411490812a4c9739ea to your computer and use it in GitHub Desktop.
Фоновое изображение по центру viewport
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
html | |
{ | |
width: 100%; | |
height: 100%; | |
background: fixed #000 url(../img/bg.jpg) 50% 50% no-repeat; | |
background-size: 100% auto; /* responsive image */ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Фоновое изображение всегда по центру viewport.
Изображение адаптивное.
Краткое описание:
width: 100%;
height: 100%; - задать размеры viewport
background-position: 50% 50%; - по центру viewport
background-attachment: fixed; - прибивает картинку к центру viewport
background-size: 100% auto; - делает фоновую картинку адаптивной, она тянется от центра во все стороны viewport