找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索本站精品资源

首页 教程频道 查看内容

css怎么在input中插图片

作者:模板之家 2021-1-11 12:27 77人关注

css在input中插图片的方法:首先在包含input的div中设置子元素span;然后设置外层div定位为relative;接着设置span定位为absolute;最后给input添加margin-left属性即可。

css在input中插图片的方法:首先在包含input的div中设置子元素;然后设置外层div定位为relative;接着设置span定位为absolute;最后给input添加margin-left属性即可。

本教程操作环境:windows7系统、HTML5&&CSS3版本、Dell G3电脑。

推荐:css视频教程

css在input里插图片

1、在包含input的div中设置子元素<span>

<div class="search">
    <span></span>
    <input type="text">
</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、效果图

5a8660d45f235884bddb638ba9d5979.png

以上就是css怎么在input中插图片的详细内容,更多请关注模板之家(www.mb5.com.cn)其它相关文章!


路过

雷人

握手

鲜花

鸡蛋
来自: 网络收集

全部回复(0)