如何为输入标签设置背景图像?

时间:2016-02-12 12:33:53

标签: css

我有这个代码atm:

<form id="" class="cf" action="">
        <div class="input_wrap cf">
            <label for="test"></label>
            <input id="test" type="text">
        </div>
    </form>

这里是css代码:

    .test {
        display: inline-block;
        max-width: 100%;
        background: url("../img/magnifying_glass_icon.svg") no-repeat right;
}

哪里有问题? 尝试了很多变种 谢谢

2 个答案:

答案 0 :(得分:2)

试试这个

#test 
{
  display: inline-block;
  max-width: 100%;
  background: url("../img/magnifying_glass_icon.svg") no-repeat scroll center right;
}

答案 1 :(得分:0)

试试这个

.test {
        display: inline-block;
        max-width: 100%;
        background: url("../img/magnifying_glass_icon.svg") no-repeat scroll center right;
}