-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathselect.html
More file actions
159 lines (146 loc) · 3.01 KB
/
Copy pathselect.html
File metadata and controls
159 lines (146 loc) · 3.01 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
<!doctype html>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
select,
::picker(select) {
appearance: base-select;
}
* {
box-sizing: border-box;
}
html {
font-family: "Helvetica", "Arial", sans-serif;
}
body {
width: 100%;
padding: 0 10px;
max-width: 480px;
margin: 0 auto;
}
p {
display: flex;
gap: 10px;
}
label {
width: fit-content;
align-self: center;
}
select {
flex: 1;
}
select {
border: 2px solid #dddddd;
background: #eeeeee;
padding: 10px;
transition: 0.4s;
}
select:hover,
select:focus {
background: #dddddd;
}
select::picker-icon {
color: #999999;
transition: 0.4s rotate;
}
select:open::picker-icon {
rotate: 180deg;
}
::picker(select) {
border: none;
}
option {
display: flex;
justify-content: flex-start;
gap: 20px;
border: 2px solid #dddddd;
background: #eeeeee;
padding: 10px;
transition: 0.4s;
}
option:first-of-type {
border-radius: 8px 8px 0 0;
}
option:last-of-type {
border-radius: 0 0 8px 8px;
}
::picker(select) {
border-radius: 8px;
}
option:not(option:last-of-type) {
border-bottom: none;
}
option:nth-of-type(odd) {
background: white;
}
option:hover,
option:focus {
background: plum;
}
selectedcontent .icon {
display: none;
}
option::checkmark {
order: 1;
margin-left: auto;
content: "☑️";
}
@supports not (appearance: base-select) {
body::before {
content: "Your browser does not support `appearance: base-select`.";
color: black;
background-color: wheat;
position: fixed;
left: 0;
right: 0;
top: 40%;
text-align: center;
padding: 1rem 0;
z-index: 1;
}
}
</style>
<form>
<p>
<label for="pet-select">Select pet:</label>
<select id="pet-select">
<button>
<selectedcontent></selectedcontent>
</button>
<option value="">Proper select</option>
<option value="cat">
<span class="icon" aria-hidden="true">🐱</span
><span class="option-label">Cat</span>
</option>
<option value="dog">
<span class="icon" aria-hidden="true">🐶</span
><span class="option-label">Dog</span>
</option>
<option value="hamster">
<span class="icon" aria-hidden="true">🐹</span
><span class="option-label">Hamster</span>
</option>
</select>
</p>
<p>
<label for="broken-select">Broken select:</label>
<select id="broken-select">
<button>
<selectedcontent></selectedcontent>
</button>
<option value="">Broken select</option>
<option value="chicken">
<span class="icon" aria-hidden="true">🐔</span
><span class="option-label">Chicken</span>
</option>
<option value="fish">
<span class="icon" aria-hidden="true">🐟</span
><span class="option-label">Fish</span>
</option>
<button>Some other button</button>
<option value="snake">
<span class="icon" aria-hidden="true">🐍</span
><span class="option-label">Snake</span>
</option>
</select>
</p>
</form>