学习了视口和弹性盒子flex布局写的小案例

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <!-- 适配移动端的适配端口 -->
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <title>填写订单</title>
    <!-- 引入字体图标 -->
    <link rel="stylesheet" href="./lib/iconfont/iconfont.css">
    <!-- 引入初始化css文件 -->
    <link rel="stylesheet" href="./css/normalize.css">
    <!-- 引入自己的页面的css -->
    <link rel="stylesheet" href="./css/order.css">
</head>
<body>
    <!-- 主体内容 -->
    <main>
        <!-- 用户订单信息 -->
        <div class="order-msg panel">
            <!-- 地址 -->
            <div class="location">
                <i class="iconfont icon-location"></i>
            </div>
            <!-- 用户信息 -->
            <div class="info">
                <p>林丽    <span>18500667882</span></p>
                <p>北京市  海淀区  中关村软件园   信息科技大厦1号楼410#</p>
            </div>
            <!-- 右边的小箭头 -->
            <div class="more">
                <i class="iconfont icon-more"></i>
            </div>
        </div>
        <!-- 商品信息模块 -->
        <div class="goods panel">
            <!-- 左边的 -->
            <div class="pic">
                <img src="./uploads/pic.png" alt="">
            </div>
            <!-- 中间的 -->
            <div class="info">
                <p>
                    康尔贝 非接触式红外体温仪
                    领券立减30元 婴儿级材质 测温…
                </p>
                <p>
                    粉色   红外体温计
                </p>
                <p>
                    <span>¥299</span>
                    <span>¥499</span>
                </p>
            </div>
            <!-- 右边的 -->
            <div class="count">
                <i class="iconfont icon-x"></i>1
            </div>
        </div>
        <!-- 配送模块 -->
        <div class="rest panel">
            <p>
                <span>配送方式</span>
                <span>顺丰快递</span>
            </p>
            <p>
                <span>买家备注</span>
                <span>希望可以尽快发货,谢谢~</span>
            </p>
            <p>
                <span>支付方式</span>
                <span>支付宝 <i class="iconfont icon-more"></i></span>
            </p>
        </div>
        <!-- 商品价格模块 -->
        <div class="amount panel">
            <p>
                <span>商品总价</span>
                <span>¥299.00</span>
            </p>
            <p>
                <span>运费</span>
                <span>¥0.00</span>
            </p>
            <p>
                <span>折扣</span>
                <span>-¥30.00</span>
            </p>
        </div>
    </main>
    <!-- 底部 -->
    <div class="pay-order">
        <div class="sun">合计:<span>¥</span><span>266.00</span></div>
        <div class="pay">
            <a href="">去支付</a>
        </div>
    </div>
</body>
</html>

body{
    background-color: #f7f7f7;
}

// 面板,相当于版心的东西
.panel{
    width: 100%;
    background-color: #ffffff;
    border-radius: 5px;
    // 面板四周距离边框有10px所以需要调整一下
    padding: 10px;
    // 每个panel的距离都有10px 所以每个向下调整10px
    margin-bottom: 10px;
}
// 主体内容
main{
    // 主体盒子距离边框有10px,下面80px是定位为了防住内容被定位覆盖
    padding: 10px 10px  80px;
    // 用户订单信息
    .order-msg{
        // 设置盒子的高度
        height: 85px;
        // 设置成为弹性容器
        display: flex;
        // 让子盒子两边靠边对齐
        justify-content: space-between;
        // 设置子盒子全部居中
        align-items: center;
        .location{
            // 左边的
            // 设置宽高和其他的东西
            width: 30px;
	        height: 30px;
	        background-image: linear-gradient(90deg, #6fc2aa 5%, #54b196 100%);
            text-align: center;
            line-height: 30px;
            // 让盒子变成一个圆
            border-radius: 50%;
            // 更改字体图标颜色
            color: #ffffff;
        }
        .info{
            // 让盒子的宽度自适应
            flex: 1;
            margin: 0 0 0 10px;
            // background-color: red;
            p{
                &:first-child{
                    // 设置第一个p的字体大小和颜色
                    font-size: 15px;
                    color: #262626;
                    span{
                        // 设置电话的字体和颜色
                        font-size: 13px;
                        color: #333333;
                    }
                }
                &:last-child{
                    // 设置下面的字体和颜色
                    margin-top: 13px;
                    font-size: 12px;
                    line-height: 18px;
                    color: #333333;
                }
            }
        }
        .more{
            // 右边的
            // 设置宽高和颜色边框
            width: 44px;
	        height: 44px;
            // 取消掉右边箭头的边框和背景色
	        // background-color: #2ad1ff;
	        // border: solid 1px #3a9cff;
            text-align: center;
            line-height: 44px;
            // 更改字体图标颜色
            color: #808080;
        }
    }
    // 商品信息模块
    .goods{
        height: 107px;
        display: flex;
        justify-content: space-between;
        align-items: center;
        // 左边的
        .pic{
            width: 85px;
            height: 85px;
            border-radius: 2px;
            img{
                width: 100%;
            }
        }
        // 中间的自适应
        .info{
            flex: 1;
            padding: 0 10px;
            p{
                &:first-child{
                    font-size: 13px;
                    line-height: 19px;
                    color: #262626;
                }
                &:nth-child(2){
                    width: 95px;
                    height: 16px;
                    background-color: #f7f7f8;
                    border-radius: 2px;
                    font-size: 12px;
                    color: #888888;
                    text-align: center;
                    line-height: 16px;
                    margin: 11px 0;
                }
                &:last-child{
                    span{
                        font-size: 16px;
                        line-height: 21px;
                        color: #cf4444;
                        &:last-child{
                            text-decoration: line-through;
                            font-size: 9px;
                            font-weight: bold;
                            line-height: 21px;
                            color: #999999;
                        }
                    }
                }
            }
        }
        // 右边的
        .count{
            // text-align: center;
            line-height: 33px;
            width: 33px;
	        height: 33px;
            color: #333333;
        }
    }
    // 配送模块
    .rest{
        height: 125px;
        background-color: #ffffff;
        border-radius: 5px;
        p{
            display: flex;
            justify-content: space-between;
            font-size: 13px;
            color: #262626;
            &:nth-child(2){
                margin: 25px 0;
                // 把第二个p单独设置从左对齐
                justify-content: flex-start;
                span{
                    &:nth-child(2){
                        margin-left: 19px;
                        font-size: 12px;
                        color: #989898;
                    }
                }
            }
        }
    }
    justify-content: space-evenly;
    // 商品价格模块
    .amount{
        p{
            font-size: 13px;
            color: #262626;
            display: flex;
            justify-content: space-between;
            &:nth-child(2){
                margin: 30px 0;
            }
            // 找到商品模块的最后一个p里面最后一个span
            &:last-child span:last-child{
                font-size: 13px;
                color: #cf4444;
            }
        }
    }
}

// 底部
.pay-order{
    position: fixed;
    left: 0;
    bottom: 0;
    width: 100%;
    height: 79px;
	background-color: #ffffff;
    // 两边都向内挤10px
    padding: 0 10px;
    // 设置成为弹性容器
    display: flex;
    // 让子盒子两边对齐
    justify-content: space-between;
    // 让子盒子垂直居中
    align-items: center;
    .sun{
        font-size: 11px;
        color: #1e1e1e;
        span{
            &:first-child{
                color: #cf4444;
            }
            &:last-child{
                font-size: 20px;
                color: #cf4444;
            }
        }
    }
    .pay{
        width: 91px;
	    height: 35px;
	    background-image: linear-gradient(90deg, #6fc2aa 5%, #54b196 100%);
	    border-radius: 3px;
        text-align: center;
        line-height: 35px;

        a{
            color: #ffffff;
        }
    }
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值