Last active
November 23, 2024 11:03
-
-
Save H-ymt/9a92fa9ef26a10836c88bef09bfbd2de to your computer and use it in GitHub Desktop.
Sassでよく使用するmixin
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
// 三点リーダー | |
@mixin line-clamp($num, $num-sp: null) { | |
display: -webkit-box; | |
-webkit-box-orient: vertical; | |
-webkit-line-clamp: $num; | |
overflow: hidden; | |
@if $num-sp { | |
@include sp { | |
-webkit-line-clamp: $num-sp; | |
} | |
} | |
} | |
// hover可能なデバイスかつ、クリック可能な要素のみhoverスタイルを適用 | |
@mixin hover { | |
@media (any-hover: hover) { | |
&:where(:any-link, :enabled, summary):hover { | |
@content; | |
} | |
} | |
} | |
// メディアクエリ | |
$breakpoints: ( | |
"sm": 576px, | |
"md": 768px, | |
"lg": 992px, | |
"xl": 1200px, | |
); | |
@mixin mq($size) { | |
@media screen and (min-width: #{map-get($breakpoints, $size)}) { | |
@content; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment