Last active
February 10, 2020 03:49
-
-
Save omega-takai/d70b526aa8bf0d258fad933d818c7762 to your computer and use it in GitHub Desktop.
複数行対応の3点リーダー省略スタイル
This file contains 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 truncateStyle($showLine: 3, $bgColor: #EEE, $fontSize: 14px, $lineHeight: 1.4) | |
background: $bgColor | |
overflow: hidden | |
font-size: $fontSize | |
max-height: $fontSize * $lineHeight * $showLine | |
line-height: $lineHeight | |
position: relative | |
&:before, | |
&:after | |
background: $bgColor | |
position: absolute | |
&:before | |
content: '...' | |
top: $fontSize * $lineHeight * ($showLine - 1) | |
right: 0 | |
width: 1em | |
&:after | |
content: '' | |
height: 100% | |
width: 100% | |
// Example | |
.truncateStyle | |
@include truncateStyle | |
width: calc(100% - 6rem) | |
margin: 2rem auto |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
DEMO: https://codepen.io/t--takai/full/LYVEJXb