【发布时间】:2023-06-08 13:24:01
【问题描述】:
【问题讨论】:
标签: javascript html google-chrome find
【问题讨论】:
标签: javascript html google-chrome find
搜索框的结构如下:
span
input
label
有一个span 元素,具有固定的宽度、高度、白色背景、边框等。在此内部是一个用于搜索字段的input 元素。这之后是一个标签元素。由于input 元素是inline-block(默认情况下),因此标签显示在它的右侧。
简单示例:
body {
background-color: #000;
}
.search-bar {
background-color: #fff;
width: 200px;
height: 30px;
}
.search-bar input {
background-color: #fff;
border: none;
}
.search-bar input:focus {
outline: none;
}
<span class="search-bar">
<input id="search" type="text" />
<label for="search">1 of 20</label>
</span>
更新:添加了 CSS 以删除 input 元素焦点上的轮廓
【讨论】:
input,但标签本身在它的右侧。它看起来好像漂浮在上面,但这只是背景混合。
<span id="searchBar"><input type="text" id="searchText" autofocus><label for="searchText">0 of 0</label></span>。我不关心它的外观,所以我只是在我的 CSS 中添加了#searchBar { height: 30px; width: 200px; }。如果它有所作为,我使用的是引导程序,而 html 是 Chrome 扩展程序的弹出窗口。