Skip to content

Commit 19cd86e

Browse files
author
Vagelis Tzortzis
committed
Add needed prefixes
* Add prefixes for flex properties * Update truncate mixin to provide fallback for firefox with a usage of a gradient instead of line-clamp
1 parent d91eb83 commit 19cd86e

File tree

1 file changed

+49
-5
lines changed
  • comparisons/components/show_hide_truncated_text

1 file changed

+49
-5
lines changed

comparisons/components/show_hide_truncated_text/scss.scss

Lines changed: 49 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,59 @@
1-
@mixin truncate($rows) {
1+
@mixin row-truncate($rows, $line-height, $background: '') {
2+
position: relative;
23
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+
}
637
}
738

839
.show-hide-text {
40+
display: -webkit-box;
41+
display: -webkit-flex;
42+
display: -ms-flexbox;
943
display: flex;
44+
-webkit-flex-wrap: wrap;
45+
-ms-flex-wrap: wrap;
1046
flex-wrap: wrap;
1147

1248
a {
49+
-webkit-box-ordinal-group: 3;
50+
-webkit-order: 2;
51+
-ms-flex-order: 2;
1352
order: 2;
1453
}
1554

1655
p {
17-
@include truncate(3);
56+
@include truncate(3, 20px, #fff); // rows, line-height, gradient fallback
1857
}
1958
}
2059

@@ -26,6 +65,11 @@
2665

2766
~ p {
2867
display: block;
68+
max-height: 100%;
69+
70+
&:after {
71+
display: none;
72+
}
2973
}
3074

3175
+ a {

0 commit comments

Comments
 (0)