Skip to content

Commit 1c60272

Browse files
committed
Allow multiline and single line, defaulting to single line, tooltips.
1 parent a9e46ec commit 1c60272

File tree

3 files changed

+36
-38
lines changed

3 files changed

+36
-38
lines changed

gulpfile.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ gulp.task('build', function() {
99
.pipe(gulp.dest('.'));
1010
});
1111

12-
gulp.task('watch', function() {
12+
gulp.task('watch', ['build'], function() {
1313
gulp.watch('src/*.css', ['default']);
1414
});
1515

src/tt.css

+34-36
Original file line numberDiff line numberDiff line change
@@ -4,50 +4,51 @@
44
}
55

66
[data-tt]::before, [data-tt]::after {
7+
border:none;
78
box-sizing: inherit;
89
display:inline-block;
9-
visibility:hidden;
10-
opacity:0;
11-
position:absolute;
12-
top:100%;
13-
left:50%;
14-
transition:all 0.2s ease-out 100ms;
15-
z-index:1000000;
16-
border:none;
1710
font-size:13px;
11+
font-style:normal;
12+
font-weight:300;
1813
line-height:18px;
14+
opacity:0;
15+
pointer-events: none;
16+
position:absolute;
17+
right:50%;
1918
text-align:center;
2019
text-decoration:none;
2120
text-shadow:none;
2221
text-transform:none;
23-
font-style:normal;
24-
font-weight:300;
22+
top:100%;
23+
transform: translateX(50%);
24+
transition:opacity 0.2s step-start 100ms;
25+
visibility:hidden;
26+
z-index:1000000;
2527
}
2628

2729
/** tooltip body **/
2830
[data-tt]::before {
29-
width:160px;
30-
content:attr(data-tt);
3131
background:rgb(51,51,51);
32-
color:#ddd;
3332
border-radius:3px;
34-
margin-left:-80px;
33+
color:#eee;
34+
content:attr(data-tt);
35+
margin:10px 0 0 0;
3536
padding:9px 13px;
37+
white-space: pre;
38+
word-wrap: break-word;
3639
}
3740

3841
/** tooltip pointer **/
3942
[data-tt]::after {
40-
content:'';
4143
border:5px solid transparent;
42-
background-color:transparent;
4344
border-bottom-color:#333;
44-
margin:-10px 0 0 -5px;
45+
content:'';
46+
margin:0 0 0 -5px;
4547
}
4648

4749
[data-tt]:hover::before, [data-tt]:hover::after {
4850
visibility:visible;
4951
opacity:1;
50-
transform: translateY(10px);
5152
}
5253

5354
/** position N, S, E or West of content based on class **/
@@ -57,44 +58,41 @@
5758
}
5859
.tt-e::before, .tt-e::after,
5960
.tt-w::before, .tt-w::after {
60-
top:50%;
61+
top:auto;
62+
bottom:50%;
63+
transform: translateY(50%);
6164
}
6265
.tt-e::before, .tt-e::after {
6366
left:100%;
67+
right:auto;
6468
}
6569
.tt-w::before, .tt-w::after {
6670
left:auto;
6771
right:100%;
6872
}
69-
.tt-e::before, .tt-w::before {
70-
margin-left:0;
71-
margin-top:-18px; /** (line-height + vertical padding) / 2 **/
73+
74+
.tt-n::before {
75+
margin:0 0 10px 0;
76+
}
77+
.tt-e::before {
78+
margin:0 0 0 10px;
79+
}
80+
.tt-w::before {
81+
margin:0 10px 0 0;
7282
}
7383

7484
.tt-n::after {
7585
border-color:transparent;
7686
border-top-color:#333;
77-
margin:0 0 -10px -5px;
87+
margin:0 0 0 5px;
7888
}
7989
.tt-e::after, .tt-w::after {
8090
border-color:transparent;
81-
margin-top:-5px; /** border size * 1 **/
91+
margin:5px 0 0 0;
8292
}
8393
.tt-e::after {
8494
border-right-color:#333;
85-
margin-left: -10px; /** border size * 2 **/
8695
}
8796
.tt-w::after {
8897
border-left-color:#333;
89-
margin-right: -10px; /** border size * 2 **/
90-
}
91-
.tt-n:hover::before,.tt-n:hover::after {
92-
transform: translateY(-10px);
9398
}
94-
.tt-e:hover::before, .tt-e:hover::after {
95-
transform: translateX(10px);
96-
}
97-
.tt-w:hover::before, .tt-w:hover::after {
98-
transform: translateX(-10px);
99-
}
100-

tt.css

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)