Created
May 5, 2015 13:27
-
-
Save nternetinspired/6e3014ae45c4c9e5f1bb to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
This file contains hidden or 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
<div class="background"> | |
<img class="center background-image" src="http://placehold.it/600x400"> | |
</div> |
This file contains hidden or 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
// ---- | |
// Sass (v3.4.13) | |
// Compass (v1.0.3) | |
// ---- | |
.background { | |
height: 400px; | |
overflow: hidden; | |
position: relative; | |
&-image { | |
background-size: cover; | |
background-position: 0 0; | |
background-repeat: no-repeat; | |
position: absolute; | |
width: 100%; | |
img { | |
width: 100%; | |
} | |
} | |
} | |
// Utility class vertically and horizontally center thing of unknown size inside a parent of unknown size. | |
.center { | |
position: absolute; | |
top: 50%; | |
left: 50%; | |
width: 100%; | |
text-align: center; | |
-webkit-transform: translate(-50%, -50%); | |
-ms-transform: translate(-50%, -50%); | |
transform: translate(-50%, -50%); | |
} |
This file contains hidden or 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
.background { | |
height: 400px; | |
overflow: hidden; | |
position: relative; | |
} | |
.background-image { | |
background-size: cover; | |
background-position: 0 0; | |
background-repeat: no-repeat; | |
position: absolute; | |
width: 100%; | |
} | |
.background-image img { | |
width: 100%; | |
} | |
.center { | |
position: absolute; | |
top: 50%; | |
left: 50%; | |
width: 100%; | |
text-align: center; | |
-webkit-transform: translate(-50%, -50%); | |
-ms-transform: translate(-50%, -50%); | |
transform: translate(-50%, -50%); | |
} |
This file contains hidden or 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
<div class="background"> | |
<img class="center background-image" src="http://placehold.it/600x400"> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment