From 7a8342a2f3fbe3bef87a32a98d55fc5fbd2de004 Mon Sep 17 00:00:00 2001 From: JoyWonderful Date: Mon, 20 Nov 2023 07:26:59 +0800 Subject: [PATCH] Modify hover-show.md. Added pointer-events --- atom.xml | 6 +-- index.html | 10 ++++- posts/hover-show/index.html | 16 ++++++-- search.xml | 4 +- sitemap.xml | 74 ++++++++++++++++++------------------- 5 files changed, 63 insertions(+), 47 deletions(-) diff --git a/atom.xml b/atom.xml index 477cfe34..24cf87e7 100644 --- a/atom.xml +++ b/atom.xml @@ -6,7 +6,7 @@ - 2023-11-12T08:30:23.880Z + 2023-11-19T23:23:15.746Z https://joywonderful.github.io/ @@ -21,9 +21,9 @@ https://joywonderful.github.io/posts/hover-show/ 2023-11-12T03:45:14.000Z - 2023-11-12T08:30:23.880Z + 2023-11-19T23:23:15.746Z - 最近弄的 github 卡片,弄了半天弄出来的鼠标悬浮显示文字的效果。使用 CSS 伪元素弄出来的小提示。但是不适合 overflow: hidden; 的元素。不管怎么说,还是很好用的,忘掉了就不太好,也就放到博客里来了。

测试:把鼠标悬浮到这段文字上会在左边显示提示
这是一个使用场景的实例(图标解说):
实例(更详细的说明)受保护的
使用场景实例猫咪 狗勾 蛙蛙 仓鼠 乌龟

代码是这样的:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
[aria-label][balloon-shown] {
position: relative;
}
[aria-label][balloon-shown="left"]::before {
border: 5px solid transparent;
border-left-color: #202335;
}
[aria-label][balloon-shown="right"]::before {
border: 5px solid transparent;
border-right-color: #202335;
}
[aria-label][balloon-shown="up"]::before {
border: 5px solid transparent;
border-top-color: #202335;
}
[aria-label][balloon-shown="down"]::before {
border: 5px solid transparent;
border-bottom-color: #202335;
}
[aria-label][balloon-shown]::before {
width: 0;
height: 0;
z-index: 10;
content: "";
position: absolute;
opacity: 0;
visibility: hidden;
transition: opacity .4s, transform .4s, visibility .4s;
}
[aria-label][balloon-shown]::after {
opacity: 0;
z-index: 10;
visibility: hidden;
background-color: #202335;
content: attr(aria-label);
white-space: nowrap;
border-radius: 2px;
position: absolute;
padding: .5em 1em;
transition: opacity .4s, transform .4s, visibility .4s;
color: #eee;
}
[aria-label][balloon-shown]:hover::after, [aria-label][balloon-shown]:hover::before {
opacity: 0.9;
visibility: visible;
}
[aria-label][balloon-shown="left"]::after {
margin-right: 10px;
}
[aria-label][balloon-shown="left"]::after, [aria-label][balloon-shown="left"]::before {
right: 100%;
top: 50%;
transform: translate(5px, -50%);
}
[aria-label][balloon-shown="right"]::after {
margin-left: 10px;
}
[aria-label][balloon-shown="right"]::after, [aria-label][balloon-shown="right"]::before {
left: 100%;
top: 50%;
transform: translate(-5px, -50%);
}
[aria-label][balloon-shown="left"]:hover::after, [aria-label][balloon-shown="left"]:hover::before, [aria-label][balloon-shown="right"]:hover::after, [aria-label][balloon-shown="right"]:hover::before {
transform: translate(0, -50%);
}
[aria-label][balloon-shown="up"]::after {
margin-bottom: 10px;
}
[aria-label][balloon-shown="up"]::after, [aria-label][balloon-shown="up"]::before {
bottom: 100%;
left: 50%;
transform: translate(-50%, 5px);
}
[aria-label][balloon-shown="down"]::after {
margin-top: 10px;
}
[aria-label][balloon-shown="down"]::after, [aria-label][balloon-shown="down"]::before {
left: 50%;
top: 100%;
transform: translate(-50%, -5px);
}
[aria-label][balloon-shown="up"]:hover::after, [aria-label][balloon-shown="up"]:hover::before, [aria-label][balloon-shown="down"]:hover::after, [aria-label][balloon-shown="down"]:hover::before {
transform: translate(-50%, 0);
}

使用时这样使用:

1
<标签 aria-label="文字" balloon-shown="up""down""left""right">文字</标签>

可以回到上面的实例部分右键选择审查元素。

]]>
+ 最近弄的 github 卡片,弄了半天弄出来的鼠标悬浮显示文字的效果。使用 CSS 伪元素弄出来的小提示。但是不适合 overflow: hidden; 的元素。不管怎么说,还是很好用的,忘掉了就不太好,也就放到博客里来了。

测试:把鼠标悬浮到这段文字上会在左边显示提示
这是一个使用场景的实例(图标解说):
实例(更详细的说明)受保护的
使用场景实例猫咪 狗勾 蛙蛙 仓鼠 乌龟

代码是这样的:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
[aria-label][balloon-shown] {
position: relative;
}
[aria-label][balloon-shown="left"]::before {
border: 5px solid transparent;
border-left-color: #202335;
}
[aria-label][balloon-shown="right"]::before {
border: 5px solid transparent;
border-right-color: #202335;
}
[aria-label][balloon-shown="up"]::before {
border: 5px solid transparent;
border-top-color: #202335;
}
[aria-label][balloon-shown="down"]::before {
border: 5px solid transparent;
border-bottom-color: #202335;
}
[aria-label][balloon-shown]::before {
width: 0;
height: 0;
/* pointer-events: none; */ /* 让鼠标无法悬浮在所弹出的伪元素上 */
z-index: 10;
content: "";
position: absolute;
opacity: 0;
visibility: hidden;
transition: opacity .4s, transform .4s, visibility .4s;
}
[aria-label][balloon-shown]::after {
opacity: 0;
z-index: 10;
/* pointer-events: none; */ /* 让鼠标无法悬浮在所弹出的伪元素上 */
visibility: hidden;
background-color: #202335;
content: attr(aria-label);
white-space: nowrap;
border-radius: 2px;
position: absolute;
padding: .5em 1em;
transition: opacity .4s, transform .4s, visibility .4s;
color: #eee;
}
[aria-label][balloon-shown]:hover::after, [aria-label][balloon-shown]:hover::before {
opacity: 0.9;
visibility: visible;
}
[aria-label][balloon-shown="left"]::after {
margin-right: 10px;
}
[aria-label][balloon-shown="left"]::after, [aria-label][balloon-shown="left"]::before {
right: 100%;
top: 50%;
transform: translate(5px, -50%);
}
[aria-label][balloon-shown="right"]::after {
margin-left: 10px;
}
[aria-label][balloon-shown="right"]::after, [aria-label][balloon-shown="right"]::before {
left: 100%;
top: 50%;
transform: translate(-5px, -50%);
}
[aria-label][balloon-shown="left"]:hover::after, [aria-label][balloon-shown="left"]:hover::before, [aria-label][balloon-shown="right"]:hover::after, [aria-label][balloon-shown="right"]:hover::before {
transform: translate(0, -50%);
}
[aria-label][balloon-shown="up"]::after {
margin-bottom: 10px;
}
[aria-label][balloon-shown="up"]::after, [aria-label][balloon-shown="up"]::before {
bottom: 100%;
left: 50%;
transform: translate(-50%, 5px);
}
[aria-label][balloon-shown="down"]::after {
margin-top: 10px;
}
[aria-label][balloon-shown="down"]::after, [aria-label][balloon-shown="down"]::before {
left: 50%;
top: 100%;
transform: translate(-50%, -5px);
}
[aria-label][balloon-shown="up"]:hover::after, [aria-label][balloon-shown="up"]:hover::before, [aria-label][balloon-shown="down"]:hover::after, [aria-label][balloon-shown="down"]:hover::before {
transform: translate(-50%, 0);
}

使用时这样使用:

1
<标签 aria-label="文字" balloon-shown="up""down""left""right">文字</标签>

可以回到上面的实例部分右键选择审查元素。

]]>
<p>最近弄的 github 卡片,弄了半天弄出来的鼠标悬浮显示文字的效果。使用 CSS 伪元素弄出来的小提示。但是不适合 <code>overflow: hidden;</code> 的元素。不管怎么说,还是很好用的,忘掉了就不太好,也就放到博客里来了。</p> diff --git a/index.html b/index.html index 08e4bba3..536234f7 100644 --- a/index.html +++ b/index.html @@ -249,9 +249,15 @@

- - + + +