<div id="container" class="angled-top-left">
<div class="content">
<h1>Angled Edge</h1>
<p>Here's the demo for applying the angled edges. Change the selections to apply the angled edge in the direction you want.</p>
<select id="selectStyle" onchange="changeStyle()">
<option value="angled-top-left">Angle Top Left</option>
<option value="angled-top-right">Angle Top Right</option>
<option value="angled-bottom-left">Angle Bottom Left</option>
<option value="angled-bottom-right">Angle Bottom Right</option>
<option value="angled-both-left">Angle Both Left</option>
<option value="angled-both-right">Angle Both Right</option>
<option value="angled-both-left-right">Angle Both Left Right</option>
<option value="angled-both-right-left">Angle Both Right Left</option>
</select>
</div>
</div>
$color1: #011627; //rgba(1, 22, 39, 100)
$color2: #fdfffc; //rgba(253, 255, 252, 100)
$color3: #2ec4b6; //rgba(46, 196, 182, 100)
$color4: #e71d36; //rgba(231, 29, 54, 100)
$color5: #ff9f1c; //rgba(255, 159, 28, 100)
body{
margin: 0;
font-family: 'Open Sans', sans-serif;
font-size: 14px;
color: #555;
}
#container{
margin-top: 100px;
height: 400px;
width: 100%;
position: relative;
}
.content{
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
background: rgba(#fff, 0.9);
border-radius: 8px;
width: 25%;
padding: 40px;
text-align: center;
box-shadow: 0 0 8px 0 rgba(0,0,0, 0.12);
box-shadow: 0 0 8px 0 rgba(0,0,0, 0.12);
h1{
font-family: Georgia, serif;
font-size: 40px;
font-weight: normal;
}
}
#selectStyle{
margin-top: 20px;
}
@mixin angle-edge($pos-top:null, $angle-top:null, $pos-btm:null, $angle-btm:null){
width: 100%;
position: relative;
background: linear-gradient(to right, rgba(241,231,103,1) 0%, rgba(254,182,69,1) 100%);
&:before,
&:after{
content: '';
width: 100%;
height: 100%;
position: absolute;
background: inherit;
z-index: -1;
transition: ease all .5s;
}
@if $pos-top{
&:before{
@if $pos-top == 'topleft'{
top: 0;
transform-origin: right top;
transform: skewY($angle-top);
}
@if $pos-top == 'topright' {
top: 0;
transform-origin: left top;
transform: skewY(-$angle-top);
}
}
}
@if $pos-btm{
&:after{
@if $pos-btm == 'bottomleft' {
bottom: 0;
transform-origin: right bottom;
transform: skewY(-$angle-btm);
}
@if $pos-btm == 'bottomright' {
bottom: 0;
transform-origin: left bottom;
transform: skewY($angle-btm);
}
}
}
}
.angled-top-left{
@include angle-edge($pos-top: topleft, $angle-top: 3deg);
}
.angled-top-right{
@include angle-edge($pos-top: topright, $angle-top: 3deg);
}
.angled-bottom-left{
@include angle-edge($pos-btm: bottomleft, $angle-btm: 3deg);
}
.angled-bottom-right{
@include angle-edge($pos-btm: bottomright, $angle-btm: 3deg);
}
.angled-both-left{
@include angle-edge(topleft, 3deg, bottomleft, 3deg);
}
.angled-both-right{
@include angle-edge(topright, 3deg, bottomright, 3deg);
}
.angled-both-left-right{
@include angle-edge(topleft, 3deg, bottomright, 3deg);
}
.angled-both-right-left{
@include angle-edge(topright, 3deg, bottomleft, 3deg);
}
View Compiled
function changeStyle() {
var x = document.getElementById("selectStyle").value;
document.getElementById("container").className = "" + x;
}
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.