我正在尝试使用IcoMoon将搜索图标添加到<input type="submit">
。我无法在<i>
内加<input>
。
我尝试使用伪elemnt :before
的方法,但不起作用。
HTML:
<div class="top-search">
<form class="navbar-form navbar-right">
<input type="text" class="form-control" placeholder="Search...">
<input type="submit" class="icon-search" value="e90e">
</form>
</div>
CSS:
@font-face {
font-family: 'icomoon';
src: url('icomoon.eot?lkqd5y');
src: url('icomoon.eot?lkqd5y#iefix') format('embedded-opentype'),
url('icomoon.ttf?lkqd5y') format('truetype'),
url('icomoon.woff?lkqd5y') format('woff'),
url('icomoon.svg?lkqd5y#icomoon') format('svg');
font-weight: normal;
font-style: normal;
}
[class^="icon-"], [class*=" icon-"] {
font-family: 'icomoon' !important;
speak: none;
font-style: normal;
font-weight: normal;
font-variant: normal;
text-transform: none;
line-height: 1;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
.icon-search:before {
content: "\e90e";
}
答案 0 :(得分:1)
<input>
元素不允许包含伪内容。您可以改用<button type="submit">
。因此,您可以直接使用:before
或添加<i>
标记。
答案 1 :(得分:0)
最后我找到了上述问题的解决方案
<input type="submit" class="icon-search" value="">