-
-
Save kontur/03057c8c90f7fd21d220abbb00363083 to your computer and use it in GitHub Desktop.
Magic Carpet... aka positioning a 100% wide element inside the layout flow
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
.magic-carpet { | |
width: 100vw; | |
position: relative; | |
left: 50%; | |
right: 50%; | |
margin-left: -50vw; | |
margin-right: -50vw; | |
// fixed height | |
height: 250px; | |
// height percent of screen | |
height: 50vh; | |
// height based on aspect ratio | |
height: 0; | |
padding-bottom: 50% // 2:1, e.g. 100% (width) / 50% (of width as height) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment