输入框的写法

代码如下
<div class="jd-header">
            <!-- 搜索框 100% 自适应 -->
            <div class="header-inner">
                <!-- 搜索框盒子 -->
                <div class="search-bar">
                    <form action="#">
                        <input type="text" placeholder="牛奶">
                    </form>
                </div>
                <!-- 京东图标 -->
                <div class="search-bar-img">
                    <img src="./img/2.png" alt="">
                </div>
                <span>|</span>
                <!-- 放大镜图标 -->
                <div class="fdj"></div>
            </div>
            <!-- 菜单按钮 -->
            <div class="menu">
                <span class="sprites_menu"></span>
            </div>
            <!-- 登录按钮 -->
            <div class="login-box">
                <span>登录</span>
            </div>
        </div>

样式如下
.jd-header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    min-width: 320px;
    max-width: 640px;
    height: 44px;
    background-color: transparent;
    .header-inner {
        width: 100%;
        height: 44px;
        padding: 7px 40px ;
        .search-bar {
            width: 100%;
            border-radius: 20px;
            height: 30px;
            overflow: hidden;
            form {
                input {
                    width: 100%;
                    height: 30px;
                    padding-left: 70px;
                }
            }
        }
        .search-bar-img {
            position: absolute;
            top: 14px;
            left: 50px;
            img {
                width: 20px;
                height: 15px;
            }
        }
        span {
            position: absolute;
            top: 13px;
            left: 75px;
            color: #e0e0e0;
        }
        .fdj {
            position: absolute;
            top: 14px;
            left: 85px;
            width: 17px;
            height: 15px;
            background: url(../img/3.png) no-repeat;
            // 精灵图的距离减小一半
            background-position: -122px 0px;
            // 整张精灵图的大小缩小一倍
            background-size: 200px 200px;
        }
    }
    .menu {
        position: absolute;
        left: 0;
        top: 0;
        width: 40px;
        height: 44px;
        .sprites_menu {
            display: inline-block;
            width: 20px;
            height: 16px;
            background: url(../img/1.png) no-repeat;
            // 原尺寸 40px*32px 一半 20*16px
            background-size: 20px 16px;
            margin: 14px 0px 0px 10px;
        }
    }
    .login-box {
        position: absolute;
        right: 0;
        top: 0;
        width: 40px;
        height: 44px;
        font-size: 14px;
        color: #fff;
        line-height: 44px; 
        text-align: center;
    }
}


上图就是代码的效果,背景色是透明的

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值