如何在占位符中添加图标

时间:2017-03-10 09:55:05

标签: html css html5 css3

how can i add this

我创建了一个邮件表单,我想在占位符中添加一个图标,如下图所示。 我该如何添加?

1 个答案:

答案 0 :(得分:3)

请查看此链接JsFiddle

<强> HTML:

<!-- Search, search, search and search! -->
<input type="search" name="search" placeholder="search" rel="search" />

<强> CSS:

input {
    background-image: url(https://cdn4.iconfinder.com/data/icons/round-mobile-ui-set/512/letter-message-email-mail-20.png);
    background-position: 10px center;
    background-repeat: no-repeat;
    border: 1px solid #ccc;

    -webkit-border-radius: 4px;
    -moz-border-radius: 4px;
    -ms-border-radius: 4px;
    -o-border-radius: 4px;
    border-radius: 4px;

    padding: 10px 5px 10px 20px;
    text-indent: 20px;

    -webkit-transition: all 0.2s;
    -moz-transition: all 2s;
    transition: all 0.2s;

    width: 200px;
}

如何在占位符中添加精彩图标, 请查看此jsFiddle