将图标放在表单中的输入元素中 [英] Put icon inside input element in a form
本文介绍了将图标放在表单中的输入元素中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在表单的输入元素中放置图标?
How do I put an icon inside a form's input element?
实时版本:潮汐力主题
推荐答案
你链接的网站使用CSS技巧的组合来解决这个问题。首先,它为< input>
元素使用背景图像。然后,为了推动光标,它使用 padding-left
。
The site you linked uses a combination of CSS tricks to pull this off. First, it uses a background-image for the <input>
element. Then, in order to push the cursor over, it uses padding-left
.
换句话说,这两个CSS规则:
In other words, they have these two CSS rules:
background: url(images/comment-author.gif) no-repeat scroll 7px 7px;
padding-left:30px;
这篇关于将图标放在表单中的输入元素中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文