Last active
November 19, 2024 14:28
-
-
Save Alecto/a60f8b246bad4fab349d52a213df1eae to your computer and use it in GitHub Desktop.
Scss mixins
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
| // Reset margin, padding, and remove list-style from a list. | |
| @mixin unlist($m: 0, $p: 0) { | |
| margin: $m; | |
| padding: $p; | |
| list-style: none; | |
| } | |
| // Truncate single-line text with ellipsis if it overflows. | |
| @mixin text-shorten { | |
| overflow: hidden; | |
| max-width: 100%; | |
| white-space: nowrap; | |
| text-overflow: ellipsis; | |
| } | |
| // Truncate multiline text with ellipsis for a specific number of lines. | |
| @mixin block-shorten($fz: 1rem, $lh: 1.5, $h: 70px, $l: 3) { | |
| display: -webkit-box; | |
| overflow: hidden; | |
| height: $h; | |
| font-size: $fz; | |
| line-height: $fz * $lh; | |
| -webkit-box-orient: vertical; | |
| -webkit-line-clamp: $l; | |
| } | |
| // Disable text selection for an element. | |
| @mixin unselectable { | |
| user-select: none; | |
| -webkit-touch-callout: none; | |
| } | |
| // Hide an element visually but keep it accessible for screen readers. | |
| @mixin visually-hidden { | |
| position: absolute; | |
| width: 1px; | |
| height: 1px; | |
| margin: -1px; | |
| border: 0; | |
| padding: 0; | |
| white-space: nowrap; | |
| clip-path: inset(100%); | |
| clip: rect(0 0 0 0); | |
| overflow: hidden; | |
| } | |
| // Apply absolute positioning with customizable offsets. | |
| @mixin abs-position($top: 0, $right: 0, $bottom: 0, $left: 0) { | |
| position: absolute; | |
| top: $top; | |
| right: $right; | |
| bottom: $bottom; | |
| left: $left; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment