Skip to content

Instantly share code, notes, and snippets.

@andrewrocco
Last active December 10, 2015 23:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andrewrocco/4512071 to your computer and use it in GitHub Desktop.
Save andrewrocco/4512071 to your computer and use it in GitHub Desktop.
Here's a way to create a white diagonal line on a black background using pseudo elements and css triangles. It works on all modern browsers, and IE8.
// Diagonal Lines
.some-element {
background: black;
position: relative;
&:before,
&:after {
border-top: 40px solid transparent;
border-bottom: 40px solid transparent;
content: "";
display: block;
height: 0;
position: absolute;
top: -40px;
width: 0;
}
&:before {
border-left: 40px solid white;
left: 1px;
}
&:after {
border-left: 40px solid black;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment