Skip to content

Instantly share code, notes, and snippets.

@einarlove
Last active August 29, 2015 14:16
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save einarlove/9c6cc7c0b7d930e5376c to your computer and use it in GitHub Desktop.
Save einarlove/9c6cc7c0b7d930e5376c to your computer and use it in GitHub Desktop.
Add retina pixel border with gradients
retinaBorder(top = false, right = false, bottom = false, left = false)
retinaGradients = ''
retinaSizes = ''
if top
retinaGradients += createGradient(top, 'top', appending: retinaGradients ? true : false)
retinaSizes = appendSize('100% 1px', retinaSizes)
if right
retinaGradients += createGradient(right, 'right', appending: retinaGradients ? true : false)
retinaSizes = appendSize('1px 100%', retinaSizes)
if bottom
retinaGradients += createGradient(bottom, 'bottom', appending: retinaGradients ? true : false)
retinaSizes = appendSize('100% 1px', retinaSizes)
if left
retinaGradients += createGradient(left, 'left', appending: retinaGradients ? true : false)
retinaSizes = appendSize('1px 100%', retinaSizes)
if retinaGradients
background: unquote(retinaGradients)
@media (-webkit-min-device-pixel-ratio: 1.5) {
background-size: unquote(retinaSizes)
}
appendSize(size, sizes)
if sizes
sizes += ','
sizes += size
createGradient(color, anchor, appending)
if anchor is 'top'
angle = 180deg
position = 'top left / 100% 2px'
if anchor is 'right'
angle = -90deg
position = 'top right / 2px 100%'
if anchor is 'bottom'
angle = 0deg
position = 'bottom right / 100% 2px'
if anchor is 'left'
angle = 90deg
position = 'bottom left / 2px 100%'
gradient = 'linear-gradient(' + angle + ',' + color + ',' + color + ' 50%, transparent 50%)' + position + ' no-repeat'
if appending
gradient = ',' + gradient
return gradient
@einarlove
Copy link
Author

.example:

@import 'retinaBorder'

.element {
  retinaBorder(bottom: #eee, right: blue)
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment