将图标放在表单中的输入元素内 [英] Put icon inside input element in a form

查看:39
本文介绍了将图标放在表单中的输入元素内的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在表单的输入元素中放置图标?

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆