-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathanchor-size-omit.html
More file actions
69 lines (65 loc) · 1.58 KB
/
anchor-size-omit.html
File metadata and controls
69 lines (65 loc) · 1.58 KB
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
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="style.css">
<title>anchor-size()の第二引数を省略する</title>
<style>
*, *::before, *::after {
box-sizing: border-box;
}
body {
margin: 0;
font-family: sans-serif;
min-height: 100vh;
display: flex;
align-items: center;
justify-content: center;
background-color: #f5f5f5;
}
.anchor {
anchor-name: --my-anchor;
width: 200px;
height: 80px;
padding: 8px 16px;
background-color: #1a73e8;
color: #fff;
border-radius: 4px;
border: none;
font-size: 1rem;
cursor: pointer;
}
.tooltip {
position: absolute;
position-anchor: --my-anchor;
position-area: center right;
/* anchor-size(width)、anchor-size(height) を省略した書き方 */
width: anchor-size();
height: anchor-size();
margin-left: 16px;
padding: 8px 16px;
background-color: #333;
color: #fff;
border-radius: 4px;
display: flex;
align-items: center;
justify-content: center;
}
.tooltip::before {
content: "";
position: absolute;
left: -6px;
top: 50%;
translate: 0 -50%;
border: 6px solid transparent;
border-left: none;
border-right-color: #333;
}
</style>
</head>
<body>
<div class="anchor">アンカー要素</div>
<div class="tooltip">アンカーと同じサイズ</div>
</body>
</html>