Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save yankeyhotel/cf0ed778f7feaafbc131 to your computer and use it in GitHub Desktop.
Save yankeyhotel/cf0ed778f7feaafbc131 to your computer and use it in GitHub Desktop.
A LESS Mixin to convert hex color values to rgba color values to be used in conjunction with the vertical gradient mixin from Bootstrap.
.hex-to-rgba-vertical-gradient ( @start-color, @start-alpha: 1, @end-color, @end-alpha ) {
// Start Color
@start-red: red(@start-color);
@start-green: green(@start-color);
@start-blue: blue(@start-color);
@start-rgba: rgba(@start-red, @start-green, @start-blue, @start-alpha);
// End Color
@end-red: red(@end-color);
@end-green: green(@end-color);
@end-blue: blue(@end-color);
@end-rgba: rgba(@end-red, @end-green, @end-blue, @end-alpha);
}
// How to use
// Using Bootstrap's gradient mixin
.alpha {
.hex-to-rgba-vertical-gradient ( @gray-middle, .5, @gray, .5 );
#gradient > .vertical(@start-rgba, @end-rgba);
}
// output
// .alpha {
// background-image: -webkit-linear-gradient(top, rgba(196, 196, 191, 0.5) 0%, rgba(155, 155, 152, 0.5) 100%);
// background-image: linear-gradient(to bottom, rgba(196, 196, 191, 0.5) 0%, rgba(155, 155, 152, 0.5) 100%);
// background-repeat: repeat-x;
// filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#80c4c4bf', endColorstr='#809b9b98', GradientType=0);
// }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment