Skip to content

Instantly share code, notes, and snippets.

@DriginCode
Created October 21, 2016 09:32
Show Gist options
  • Save DriginCode/b25aa81aa24eca628e79e7ae36751dce to your computer and use it in GitHub Desktop.
Save DriginCode/b25aa81aa24eca628e79e7ae36751dce to your computer and use it in GitHub Desktop.
responsive-image
Если ты используешь картинку как фон в header используй:
header{
background:url(path_to_your_image) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
height: 100px;
}
Пример: https://jsfiddle.net/NikitaSmith/uz2n1r3p/4/
Если ты хочешь использовать картину внутри блока,чтобы она была адаптивной: HTML:
<img src="path/to/your/image" alt="">
</header>
CSS:
#background {
position: fixed;
top: 0;
left: 0;
/* Preserve aspet ratio */
min-width: 100%;
height: 200px;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment