-
-
Save stevenh512/2730440 to your computer and use it in GitHub Desktop.
Faded/Gradient Borders in Pure CSS
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/css3"; | |
@mixin gradient-border($width: 28%, $float: right) { | |
width: $width; | |
float: $float; | |
overflow: hidden; | |
border-width: 0 0 0 1px; | |
@include box-shadow(inset 15px 0 5px -16px rgba(0,0,0,.1), -1px 0 0 #FFF); | |
@include border-image(linear-gradient(top, rgba(0,0,0,.09), rgba(0,0,0,0)) 1 100%) | |
} |
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
.border-container { | |
width: 28%; /* border will be on the left on this container */ | |
float: right; | |
overflow: hidden; /* only needed if floating container */ | |
min-height: 600px; /* static height if you want your container to be taller than its content */ | |
-moz-box-shadow: inset 15px 0 5px -16px rgba(0,0,0,.1), -1px 0 0 #FFF; | |
-webkit-box-shadow: inset 15px 0 5px -16px rgba(0,0,0,.1), -1px 0 0 #FFF; | |
box-shadow: inset 15px 0 5px -16px rgba(0,0,0,.1), -1px 0 0 #FFF; | |
border-width: 0 0 0 1px; | |
-webkit-border-image: | |
-webkit-gradient(linear, 0 100%, 0 0, from(rgba(0,0,0,.09)), to(rgba(0,0,0,0))) 1 100%; | |
-webkit-border-image: | |
-webkit-linear-gradient(top, rgba(0,0,0,.09), rgba(0,0,0,0)) 1 100%; | |
-moz-border-image: | |
-moz-linear-gradient(top, rgba(0,0,0,.09), rgba(0,0,0,0)) 1 100%; | |
} |
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> | |
<head> | |
<title>Gradient borders</title> | |
<link rel="stylesheet" href="stylesheets/screen.css" type="text/css" /> | |
</head> | |
<body> | |
<div class="border-container"> | |
<div class="content"> | |
Ohai! | |
</div> | |
</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
# Require any additional compass plugins here. | |
# Set this to the root of your project when deployed: | |
http_path = "/" | |
css_dir = "stylesheets" | |
sass_dir = "sass" | |
images_dir = "images" | |
javascripts_dir = "javascripts" | |
# You can select your preferred output style here (can be overridden via the command line): | |
# output_style = :expanded or :nested or :compact or :compressed | |
# To enable relative paths to assets via compass helper functions. Uncomment: | |
# relative_assets = true | |
# To disable debugging comments that display the original location of your selectors. Uncomment: | |
# line_comments = false | |
# If you prefer the indented syntax, you might want to regenerate this | |
# project again passing --syntax sass, or you can uncomment this: | |
# preferred_syntax = :sass | |
# and then run: | |
# sass-convert -R --from scss --to sass sass scss && rm -rf sass && mv scss 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
@import "gradient-border"; | |
.border-container { | |
min-height: 600px; | |
@include gradient-border; | |
} | |
.content { | |
margin-top: 50px; | |
margin-bottom: 50px; | |
text-align: center; | |
font-size: 150%; | |
font-weight: bold; | |
} |
I ended up making another mixin that uses the "div inside a div", too, see this gist. It's mostly based on this one and something I saw on StackOverflow.
Thanks for the link, playing with Compass again for these gists (and seeing some of the cool things that are possible with CSS in a modern browser) has sparked my interest in design.. so I'll probably be referring to that site quite a bit.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
http://css-tricks.com/examples/GradientBorder/
Chris Coyier is a mad css scientist.
I take the strange route of accomplishing the same effect by putting a div inside a div and... I don't know!