Skip to content

Commit 7de6736

Browse files
committed
style(ui): 调整搜索框样式并修复SVG图标尺寸
- 统一搜索框的内边距 - 隐藏原生搜索框清除按钮 - 为清除按钮添加z-index - 为所有SVG图标添加明确的宽高属性
1 parent 06713bc commit 7de6736

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

index.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
<div class="header-content">
7474
<div class="header-left">
7575
<h1 class="title">
76-
<svg class="icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" aria-hidden="true">
76+
<svg class="icon" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" aria-hidden="true">
7777
<path d="M9 12l2 2 4-4"/>
7878
<path d="M21 12c-1 0-3-1-3-3s2-3 3-3 3 1 3 3-2 3-3 3"/>
7979
<path d="M3 12c1 0 3-1 3-3s-2-3-3-3-3 1-3 3 2 3 3 3"/>
@@ -128,7 +128,7 @@ <h2 class="sr-only">Search USB Devices and Vendors</h2>
128128
<div class="search-container">
129129
<div class="search-box">
130130
<label for="searchInput" class="sr-only">Search USB vendors and devices</label>
131-
<svg class="search-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" aria-hidden="true">
131+
<svg class="search-icon" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" aria-hidden="true">
132132
<circle cx="11" cy="11" r="8"/>
133133
<path d="m21 21-4.35-4.35"/>
134134
</svg>
@@ -141,7 +141,7 @@ <h2 class="sr-only">Search USB Devices and Vendors</h2>
141141
autocomplete="off"
142142
>
143143
<button id="clearSearch" class="clear-btn" style="display: none;" aria-label="Clear search">
144-
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" aria-hidden="true">
144+
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" aria-hidden="true">
145145
<line x1="18" y1="6" x2="6" y2="18"/>
146146
<line x1="6" y1="6" x2="18" y2="18"/>
147147
</svg>
@@ -201,7 +201,7 @@ <h2 class="sr-only">Search Results</h2>
201201

202202
<!-- Empty State -->
203203
<div id="emptyState" class="empty-state" style="display: none;" role="status">
204-
<svg class="empty-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" aria-hidden="true">
204+
<svg class="empty-icon" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" aria-hidden="true">
205205
<circle cx="11" cy="11" r="8"/>
206206
<path d="m21 21-4.35-4.35"/>
207207
</svg>

src/styles.css

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,14 +235,25 @@ html {
235235

236236
.search-input {
237237
width: 100%;
238-
padding: 1rem 1rem 1rem 3rem;
238+
padding: 1rem 3rem 1rem 3rem;
239239
border: 2px solid var(--border-color);
240240
border-radius: var(--radius-lg);
241241
font-size: 1rem;
242242
background: var(--surface-color);
243243
transition: var(--transition);
244244
}
245245

246+
/* Hide native search input clear button */
247+
.search-input::-webkit-search-cancel-button {
248+
-webkit-appearance: none;
249+
appearance: none;
250+
}
251+
252+
.search-input::-webkit-search-decoration {
253+
-webkit-appearance: none;
254+
appearance: none;
255+
}
256+
246257
.search-input:focus {
247258
outline: none;
248259
border-color: var(--primary-color);
@@ -277,6 +288,7 @@ html {
277288
justify-content: center;
278289
width: 2rem;
279290
height: 2rem;
291+
z-index: 10;
280292
}
281293

282294
.clear-btn:hover {

0 commit comments

Comments
 (0)