css怎么在input中插图片
时间:2021-01-11 来源:互联网
css怎么在input中插图片呢?首先在包含input的div中设置子元素;然后设置外层div定位为relative;接着设置span定位为absolute;最后给input添加margin-left属性即可。下面PHP爱好者分享的css怎么在input中插图片方法教程,希望对大家有所帮助。
css怎么在input中插图片
本教程操作环境: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;
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、效果图
相关阅读更多 +
-
体育老师又去开会了 2025-05-31
-
币安怎么购买POL币?POL购买教程与币安binance下载入口 2025-05-31
-
崩坏星穹铁道无果之树成就怎么达成-崩坏星穹铁道无果之树成就达成攻略 2025-05-31
-
鸿蒙系统2.0安装教程 2025-05-31
-
燕云十六声神秘驻地据点如何占领-燕云十六声神秘驻地据点怎么占领 2025-05-31
-
币安怎么购买Ethena币?Ethena购买教程与币安binance下载入口 2025-05-31
最近更新