Created
May 16, 2012 08:29
-
-
Save christianhanvey/2708702 to your computer and use it in GitHub Desktop.
Ribbons
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Compass Flag/Ribbon Mixins · CodePen</title> | |
<style> | |
.element { | |
-webkit-border-radius: 8px; | |
-moz-border-radius: 8px; | |
-ms-border-radius: 8px; | |
-o-border-radius: 8px; | |
border-radius: 8px; | |
-webkit-box-shadow: 0 2px 3px rgba(0, 0, 0, 0.1); | |
-moz-box-shadow: 0 2px 3px rgba(0, 0, 0, 0.1); | |
box-shadow: 0 2px 3px rgba(0, 0, 0, 0.1); | |
display: -moz-inline-box; | |
-moz-box-orient: vertical; | |
display: inline-block; | |
vertical-align: middle; | |
*vertical-align: auto; | |
width: 150px; | |
height: 130px; | |
background: #ebebeb; | |
border: 1px solid #ccc; | |
margin: 10px; | |
position: relative; | |
} | |
.element { | |
*display: inline; | |
} | |
.horiz-flag { | |
-webkit-box-shadow: 0px 1px 1px rgba(0, 0, 0, 0.35); | |
-moz-box-shadow: 0px 1px 1px rgba(0, 0, 0, 0.35); | |
box-shadow: 0px 1px 1px rgba(0, 0, 0, 0.35); | |
background-image: -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(0%, #9fbfdc), color-stop(100%, #3c74a6)); | |
background-image: -webkit-linear-gradient(#9fbfdc, #3c74a6); | |
background-image: -moz-linear-gradient(#9fbfdc, #3c74a6); | |
background-image: -o-linear-gradient(#9fbfdc, #3c74a6); | |
background-image: -ms-linear-gradient(#9fbfdc, #3c74a6); | |
background-image: linear-gradient(#9fbfdc, #3c74a6); | |
display: -moz-inline-box; | |
-moz-box-orient: vertical; | |
display: inline-block; | |
vertical-align: middle; | |
*vertical-align: auto; | |
height: 40px; | |
line-height: 40px; | |
position: absolute; | |
padding-right: 40px; | |
left: -2px; | |
padding-left: 10px; | |
top: 10px; | |
color: #fff; | |
} | |
.horiz-flag { | |
*display: inline; | |
} | |
.horiz-flag:before { | |
content: ''; | |
display: block; | |
height: 0; | |
width: 0; | |
border-style: solid; | |
border-width: 20px; | |
border-color: transparent; | |
border-right-color: #ebebeb; | |
position: absolute; | |
right: -1px; | |
top: 0; | |
} | |
.vert-flag { | |
-webkit-box-shadow: 1px 0 1px rgba(0, 0, 0, 0.35); | |
-moz-box-shadow: 1px 0 1px rgba(0, 0, 0, 0.35); | |
box-shadow: 1px 0 1px rgba(0, 0, 0, 0.35); | |
background-image: -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(0%, #e72929), color-stop(100%, #6b0c0c)); | |
background-image: -webkit-linear-gradient(#e72929, #6b0c0c); | |
background-image: -moz-linear-gradient(#e72929, #6b0c0c); | |
background-image: -o-linear-gradient(#e72929, #6b0c0c); | |
background-image: -ms-linear-gradient(#e72929, #6b0c0c); | |
background-image: linear-gradient(#e72929, #6b0c0c); | |
display: -moz-inline-box; | |
-moz-box-orient: vertical; | |
display: inline-block; | |
vertical-align: middle; | |
*vertical-align: auto; | |
text-align: center; | |
width: 50px; | |
position: absolute; | |
padding-bottom: 50px; | |
top: -2px; | |
padding-top: 10px; | |
left: 10px; | |
color: #fff; | |
} | |
.vert-flag { | |
*display: inline; | |
} | |
.vert-flag:before { | |
content: ''; | |
display: block; | |
height: 0; | |
width: 0; | |
border-style: solid; | |
border-width: 25px; | |
border-color: transparent; | |
left: 0; | |
border-bottom-color: #ebebeb; | |
position: absolute; | |
bottom: -1px; | |
} | |
</style> | |
</head> | |
<body> | |
<div class='element'> | |
<span class='horiz-flag'>some text</span> | |
</div> | |
<div class='element'> | |
<span class='vert-flag'>ribbon text</span> | |
</div> | |
</body> | |
</html> |
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
.element | |
%span.horiz-flag some text | |
.element | |
%span.vert-flag ribbon text |
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
@import "compass"; | |
@mixin horiz-flag($color, $notch-color, $height, $notch-side) { | |
@include box-shadow(0px 1px 1px rgba(0,0,0,0.35)); | |
@include background-image(linear-gradient(lighten($color, 20%), darken($color, 10%))); | |
@include inline-block; | |
height: $height; | |
line-height: $height; | |
position: absolute; | |
padding-#{$notch-side}: $height; | |
@if $notch-side == left { | |
right: -2px; | |
padding-right: 10px; | |
text-align: right; | |
} @else { | |
left: -2px; | |
padding-left: 10px; | |
} | |
&:before { | |
content: ''; | |
display: block; | |
height: 0; | |
width: 0; | |
border-style: solid; | |
border-width: $height/2; | |
border-color: transparent; | |
border-#{$notch-side}-color: $notch-color; | |
position: absolute; | |
#{$notch-side}: -1px; | |
top: 0; | |
} | |
} | |
@mixin vert-flag($color, $notch-color, $width, $notch-side) { | |
@include box-shadow(1px 0 1px rgba(0,0,0,0.35)); | |
@include background-image(linear-gradient(lighten($color, 20%), darken($color, 10%))); | |
@include inline-block; | |
text-align: center; | |
width: $width; | |
position: absolute; | |
padding-#{$notch-side}: $width; | |
@if $notch-side == bottom { | |
top: -2px; | |
padding-top: 10px; | |
} @else { | |
bottom: -2px; | |
padding-bottom: 10px; | |
} | |
&:before { | |
content: ''; | |
display: block; | |
height: 0; | |
width: 0; | |
border-style: solid; | |
border-width: $width/2; | |
border-color: transparent; | |
left: 0; | |
border-#{$notch-side}-color: $notch-color; | |
position: absolute; | |
#{$notch-side}: -1px; | |
} | |
} | |
// just an element to hold the flag | |
.element { | |
@include border-radius(8px); | |
@include box-shadow(0 2px 3px rgba(0,0,0,0.1)); | |
@include inline-block; | |
width: 150px; | |
height: 130px; | |
background: #ebebeb; | |
border: 1px solid #ccc; | |
margin: 10px; | |
position: relative; | |
} | |
// and then the flags... | |
.horiz-flag { | |
@include horiz-flag(#548ec1, #ebebeb, 40px, right); | |
top: 10px; | |
color: #fff; | |
} | |
.vert-flag { | |
@include vert-flag(#911, #ebebeb, 50px, bottom); | |
left: 10px; | |
color: #fff; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment