【发布时间】:2018-04-03 15:34:11
【问题描述】:
我试图在我的搜索栏中使用search icon from fontawesome 而不是background-image,它使用过渡来扩展输入区域。单击此图标,该区域应打开。
我试过了
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>
<input type="text" name="eingabe" placeholder="Suche">
<i class="fa fa-search" aria-hidden="true"></i>
</input>
但是符号在输入旁边,我不能点击它来使用我的过渡来擦除我输入的宽度。
@Saurav 几乎解决了我的问题,但我无法点击图标。
.search-bar {
position: relative;
}
.search-bar .icon {
position: absolute;
top: 47%;
left: 10px;
transform: translateY(-50%);
}
.search-bar .input-text {
width: 0px;
border: 0px;
background-color: #fff;
height: 20px;
padding: 8px 8px 8px 35px;
-webkit-transition: width 0.4s ease-in-out;
transition: width 0.4s ease-in-out;
}
.search-bar .input-text:focus {
width: 80%;
background-color: #ccc;
}
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>
<div class="search-bar">
<i class="icon fa fa-search"></i>
<input class="input-text" type="text" name="eingabe" placeholder="Suche">
</div>
【问题讨论】:
-
请提供实时网址
-
@flowerflower 我已经更新了我的答案,请看一下。
标签: html css font-awesome