【问题标题】:how to append an icon to an input search?如何将图标附加到输入搜索?
【发布时间】:2015-04-22 15:37:15
【问题描述】:

我正在尝试将图标附加到输入。

使用 font awesome 可以将该图标附加到输入的值上,如下所示:

<input class="btn" type="submit" value="&#xf090;">

其中value="&amp;#xf090;" 相当于&lt;i class="fa fa-sign-in"&gt;&lt;/i&gt;,到目前为止这是完美的,但我需要那个图标更大,我怎样才能做到这一点?或者将该图标附加到输入的其他方法是什么?

和css

input[type="submit"] {
    font-family: FontAwesome;
}

并且图标必须附在左边。

【问题讨论】:

  • Yisus,@Adrift 不是重复的,看看我问的地方:value="&amp;#xf090;" 相当于&lt;i class="fa fa-sign-in"&gt;&lt;/i&gt;,到目前为止这是完美的,但我需要那个图标更大,如何我能做到吗?
  • @Adrift 我在问如何让我在value="&amp;#xf090;" 上的图标变大与其他问题无关

标签: css twitter-bootstrap font-awesome


【解决方案1】:

我会使用&lt;button type="submit"&gt;&lt;/button&gt;

@font-face {
  font-family: FontAwasome;
  src: url("https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.3.0/fonts/fontawesome-webfont.woff");
}

.sign-in:after {
  content: '';
  display: inline-block;
  font-family: FontAwasome;
  font-size: 2em;
  line-height: 2.75rem;
  height: 2.75rem;
  vertical-align: top;
}

button {
  background-color: blue;
  border: none;
  color: white;
  min-height: 2.75em;
  margin: 0;
  padding: 0 1em;
}
&lt;button type="submit" class="sign-in"&gt;&lt;/button&gt;

【讨论】:

    猜你喜欢
    • 2012-12-10
    • 1970-01-01
    • 2020-10-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-10-09
    相关资源
    最近更新 更多