Skip to content

Instantly share code, notes, and snippets.

@Artur-Sulej
Created November 30, 2015 11:18
Show Gist options
  • Save Artur-Sulej/9f354ffaf195914c2b89 to your computer and use it in GitHub Desktop.
Save Artur-Sulej/9f354ffaf195914c2b89 to your computer and use it in GitHub Desktop.
CSS class making image fit screen width
<style type="text/css">
.img_fitted {
background-position: center;
background-size:cover;
width: 100%;
color: #fff;
}
.img_fitted img {
max-width: 100%;
}
</style>
<!-- ... -->
<div class="img_fitted" style="background-image: url(background)">
<!-- ... -->
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment