css在input中插图片的方法:首先在包含input的div中设置子元素;然后设置外层div定位为relative;接着设置span定位为absolute;最后给input添加margin-left属性即可。
本教程操作环境:windows7系统、HTML5&&CSS3版本、Dell G3电脑。
推荐:css视频教程
css在input里插图片
1、在包含input的div中设置子元素
立即学习“前端免费学习笔记(深入)”;
登录后复制
2、设置外层div定位为relative
.search{ position: relative;}
登录后复制
3、设置span定位为absolute,并设置宽高和背景图片
.search > span{ position: absolute; display: inline-block; width: 20px; height: 20px; background: url(./search.png) no-repeat; background-size: 80% 80%; background-position: center;}
登录后复制
4、给input添加margin-left属性。
.search > input{ width: 100%; padding-left: 20px;}
登录后复制
5、效果图
以上就是css怎么在input中插图片的详细内容,更多请关注【创想鸟】其它相关文章!
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至253000106@qq.com举报,一经查实,本站将立刻删除。
发布者:PHP中文网,转转请注明出处:https://www.chuangxiangniao.com/p/2881289.html