|
1 | | -@mixin truncate($rows) { |
| 1 | +@mixin row-truncate($rows, $line-height, $background: '') { |
| 2 | + position: relative; |
2 | 3 | overflow: hidden; |
3 | | - display: -webkit-box; |
4 | | - -webkit-line-clamp: $rows; |
5 | | - -webkit-box-orient: vertical; |
| 4 | + max-height: $line-height * $rows; |
| 5 | + line-height: $line-height; |
| 6 | + |
| 7 | + &:after { |
| 8 | + content: ""; |
| 9 | + position: absolute; |
| 10 | + right: 0; |
| 11 | + bottom: 0; |
| 12 | + width: 100px; |
| 13 | + height: $line-height; |
| 14 | + |
| 15 | + @if $background != '' { |
| 16 | + background: -moz-linear-gradient(left, rgba($background, 0) 0%, rgba($background, 1) 100%); |
| 17 | + background: -webkit-gradient(linear, left top, right top, color-stop(0%, rgba($background, 0)), color-stop(100%, rgba($background, 1))); |
| 18 | + background: -webkit-linear-gradient(left, rgba($background, 0) 0%,rgba($background, 1) 100%); |
| 19 | + background: -o-linear-gradient(left, rgba($background, 0) 0%, rgba($background, 1) 100%); |
| 20 | + background: -ms-linear-gradient(left, rgba($background, 0) 0%, rgba($background, 1) 100%); |
| 21 | + background: linear-gradient(to right, rgba($background, 0) 0%, rgba($background, 1) 100%); |
| 22 | + } |
| 23 | + } |
| 24 | + |
| 25 | + // If supports line-clamp then add an ellipsis overflow and hide the gradient |
| 26 | + // This will work in Chrome and Opera, otherwise a gradient will gradually hide the text. |
| 27 | + |
| 28 | + @supports (-webkit-line-clamp: $rows) { |
| 29 | + display: -webkit-box; |
| 30 | + -webkit-line-clamp: $rows; |
| 31 | + -webkit-box-orient: vertical; |
| 32 | + |
| 33 | + &:after { |
| 34 | + display: none; |
| 35 | + } |
| 36 | + } |
6 | 37 | } |
7 | 38 |
|
8 | 39 | .show-hide-text { |
| 40 | + display: -webkit-box; |
| 41 | + display: -webkit-flex; |
| 42 | + display: -ms-flexbox; |
9 | 43 | display: flex; |
| 44 | + -webkit-flex-wrap: wrap; |
| 45 | + -ms-flex-wrap: wrap; |
10 | 46 | flex-wrap: wrap; |
11 | 47 |
|
12 | 48 | a { |
| 49 | + -webkit-box-ordinal-group: 3; |
| 50 | + -webkit-order: 2; |
| 51 | + -ms-flex-order: 2; |
13 | 52 | order: 2; |
14 | 53 | } |
15 | 54 |
|
16 | 55 | p { |
17 | | - @include truncate(3); |
| 56 | + @include truncate(3, 20px, #fff); // rows, line-height, gradient fallback |
18 | 57 | } |
19 | 58 | } |
20 | 59 |
|
|
26 | 65 |
|
27 | 66 | ~ p { |
28 | 67 | display: block; |
| 68 | + max-height: 100%; |
| 69 | + |
| 70 | + &:after { |
| 71 | + display: none; |
| 72 | + } |
29 | 73 | } |
30 | 74 |
|
31 | 75 | + a { |
|
0 commit comments