Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save gorrillamcd/3493256 to your computer and use it in GitHub Desktop.

Select an option

Save gorrillamcd/3493256 to your computer and use it in GitHub Desktop.
SCSS cross browser rounded corner mixins
/* ===== Rounded Corners ===== */
$default_rounded_amount: 20px;
// Round corner at position by amount.
@mixin round-corner($position, $amount: $default_rounded_amount) {
border-#{$position}-radius: $amount;
-webkit-border-#{$position}-radius: $amount;
}
@mixin round-corner-mozilla($position, $amount: $default_rounded_amount) {
-moz-border-radius-#{$position}: $amount;
}
// Round left corners by amount
@mixin round-left-corners($amount: $default_rounded_amount) {
@include round-corner("top-left", $amount);
@include round-corner("bottom-left", $amount);
@include round-corner-mozilla("topleft", $amount);
@include round-corner-mozilla("bottomleft", $amount);
}
// Round right corners by amount
@mixin round-right-corners($amount: $default_rounded_amount) {
@include round-corner("top-right", $amount);
@include round-corner("bottom-right", $amount);
@include round-corner-mozilla("topright", $amount);
@include round-corner-mozilla("bottomright", $amount);
}
// Round top corners by amount
@mixin round-top-corners($amount: 5px) {
@include round-corner("top-left", $amount);
@include round-corner("top-right", $amount);
@include round-corner-mozilla("topleft", $amount);
@include round-corner-mozilla("topright", $amount);
}
// Round bottom corners by amount
@mixin round-bottom-corners($amount: $default_rounded_amount) {
@include round-corner("bottom-left", $amount);
@include round-corner("bottom-right", $amount);
@include round-corner-mozilla("bottomleft", $amount);
@include round-corner-mozilla("bottomright", $amount);
}
// Round all corners by amount
@mixin round-corners($amount: $default_rounded_amount) {
border-radius: $amount;
-moz-border-radius: $amount;
-webkit-border-radius: $amount;
}
// Round bottom-side corners (either left or right)
@mixin round-any-corner($vert, $side, $amount: $default_rounded_amount) {
@include round-corner("#{$vert}-#{$side}", $amount);
@include round-corner-mozilla("#{$vert}#{$side}", $amount);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment