我嘗試將圖標放入文本輸入字段。
實施例:
將圖標放入文本輸入字段
的一個解決方案是使用背景圖像,然後使用填充左。
但我想用css精靈。我試過下面的代碼:
<!DOCTYPE html>
<html>
<head>
<style type="text/css">
.input {
padding-left:35px;
width: 128px;
background: Red;
}
.sprite:before{
background: url('http://img45.imageshack.us/img45/4259/buildingssheet7dv.png');
content: " ";
position: absolute;
height:32px;
width:32px;
margin: -10px 0 0 -10px;
z-index:100;
}
.sprite:before {
background-position: -32px 0;
}
</style>
</head>
<body>
<input type="text" class="input sprite"></input>
</body>
</html>
我在做什麼錯?