我們?cè)谧鼍W(wǎng)頁(yè)的時(shí)候,經(jīng)常需要在input里面添加小圖標(biāo),那么這里就介紹比較常見的兩種方法。
方法一
將小圖標(biāo)當(dāng)做input的背景來(lái)插入,直接上代碼吧:
<style type="text/css"> *{ margin: 0; padding: 0; } input{ border: none; } .box{ height: 50px; background: yellow; } .box input{ width: 200px; height: 30px; border-radius: 15px; margin: 10px 0; background: url(image/search.gif) no-repeat; background-color: white; background-position: 3px; padding-left: 30px; border: 1px solid black; outline: none; } </style> </head> <body> <div class="box"> <input type="text" class="username" value="搜索"/> </div> </body>
方法二
使用 i 標(biāo)簽插入
<style type="text/css"> *{ margin: 0; padding: 0; } .box{ width: 200px; position: relative; } .box .icon-search{ background: url(image/search.gif) no-repeat; width: 20px; height: 20px; position: absolute; top: 6px; left: 0; } .box .username{ padding-left: 30px; height: 25px; } </style> </head> <body> <div class="box"> <i class="icon-search"></i> <input type="text" class="username" value="搜索"/> </div> </body>
總結(jié)
以上所述是小編給大家介紹的JS Input里添加小圖標(biāo)的兩種方法,希望對(duì)大家有所幫助,如果大家有任何疑問(wèn)歡迎給我留言,小編會(huì)及時(shí)回復(fù)大家的!
Copyright ? 2019- 91gzw.com 版權(quán)所有 湘ICP備2023023988號(hào)-2
違法及侵權(quán)請(qǐng)聯(lián)系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com
本站由北京市萬(wàn)商天勤律師事務(wù)所王興未律師提供法律服務(wù)