Last active
June 15, 2017 14:46
-
-
Save kovtunos/2b4a88cccc3fcab82a4ec4e3774df344 to your computer and use it in GitHub Desktop.
Slanting section #svg #html #css #sass
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
// HTML | |
<section> | |
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="0 0 100 100" preserveAspectRatio="none" id="skew-top"> | |
<polygon points="0,0 0,100 100,0"/> | |
</svg> | |
... | |
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="0 0 100 100" preserveAspectRatio="none" id="skew-bottom"> | |
<polygon points="0,100 100,0 100,100"/> | |
</svg> | |
</section> | |
// CSS | |
section { | |
position: relative; | |
overflow-x: hidden; | |
} | |
#skew-top, | |
#skew-bottom { | |
position: absolute; | |
width: 100%; | |
height: 2vw; /* keeps angle constant, use px if you want otherwise */ | |
fill: white; | |
stroke-width: 0; | |
} | |
#skew-top { | |
top: 0; | |
} | |
#skew-bottom { | |
bottom: 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment