【发布时间】:2021-11-12 09:24:42
【问题描述】:
我想知道如何在文本框中对齐搜索图标,与 Google 的搜索栏相同
像这样:
这就是我得到的,但是我知道怎么做:
我试图避免使用引导程序或任何库。我想尽可能保持原味。
#search-bar {
width: 32%;
color: white;
border-radius: 24px;
border-style: solid;
border-width: 1px;
border-color: white;
background-color: #2d2d2d;
height: 44px;
}
<form class="search-bar-form">
<input id="search-bar" type="text" href="#" />
<img src="https://via.placeholder.com/24" />
</form>
【问题讨论】:
-
可以将您的样式文本框切换为 div,然后像使用文本框一样对其进行样式设置,在其中添加图像并在其旁边添加文本框?