.underline-input {
border: none;
border-bottom: 1px solid #333; /* 僅保留底線 */
background: transparent;
outline: none;
padding: 4px 2px;
font-size: 16px;
width: 200px;
}
.underline-input:focus {
border-bottom-color: #0066cc;
}
<p>用戶名:<input type="text" name="username" class="underline-input"></p>
<p>密碼:<input type="password" name="pwd" class="underline-input"></p>
transition: border-color .2s, box-shadow .2s; + box-shadow: 0 1px 0 0 currentColor;:read-only { border-bottom-style: dashed; color: #999; }保留 :focus 明顯樣式,確保鍵盤使用者能識別焦點位置;勿移除 outline 除非提供等效替代指示器。