【HTML+CSS】pink老师课后作业1——购物格模块的实现

【HTML+CSS】pink老师课后作业1——购物格模块的实现

题目如题所示

第一次接触前端知识,可能这是你见过最笨的办法~ 但是成功了嗷 给大家提供一个思路吧~

基本思路

先框架后样式

  1. 把整个布局看作是不同大小的盒子组合而成:
    在这里插入图片描述
    HTML代码如下:
<body>
    <div class="father">
        <!-- 图片展示 -->
        <div class="pic">
            <img src="images/huawei.png" alt="">
        </div>
        <!-- 文字说明 -->
        <p class="text">HUAWEI Mate 40 Pro+ 5G</p>
        <!-- 价格 -->
        <div class="money">
            <span class="youhui">&yen;6088</span>
            <span class="yuanjia">&yen;6988</span>
        </div>
        <!-- 进度条 -->
        <div class="jdt">
            <span class="content1">已售87%</span>
            <div class="bar">
                <div class="bar-in"></div>
            </div>
            <span class="content2">剩余27件</span>
        </div>
        <!-- 立即抢购按钮 -->
        <!-- <input type="button" value="立即抢购"> -->
        <a href="#">立即抢购</a>

    </div>
</body>
  1. 按照每个小模块添加对应的样式
    <style>
        * {
            margin: 0;
            padding: 0;
        }
        
        .father {
            width: 235px;
            height: 295px;
            margin: 10px auto;
        }
        
        .pic {
            width: 115px;
            height: 150px;
            margin: 0 auto;
            padding-top: 20px;
        }
        
        .pic img {
            width: 115px;
            height: 150px;
        }
        
        .text {
            width: 235px;
            height: 21px;
            /* 单行文字垂直居中 */
            line-height: 21px;
            /* 单行文字水平居中 */
            text-align: center;
            font-size: 14px;
            color: #3a3a3a;
            padding-top: 5px;
        }
        
        .money {
            width: 205px;
            height: 21px;
            /* 单行文字垂直居中 */
            line-height: 21px;
            /* 单行文字水平靠左 */
            text-align: lefter;
            padding-top: 5px;
            padding-left: 30px;
        }
        
        .money .youhui {
            font-size: 16px;
            color: red;
        }
        
        .money .yuanjia {
            font-size: 12px;
            color: #777777;
            text-decoration: line-through;
        }
        
        .jdt {
            position: relative;
            width: 235px;
            height: 21px;
        }
        
        .bar {
            width: 116px;
            height: 7px;
            border: 1px solid red;
            border-radius: 7px;
            padding: 1px;
            margin: 10px auto;
        }
        
        .bar-in {
            width: 87%;
            height: 100%;
            background-color: red;
            border-radius: 7px;
            transition: all .7s;
        }
        
        .bar:hover .bar-in {
            width: 100%;
        }
        
        .jdt .content1 {
            position: absolute;
            left: 5px;
            top: 0;
            font-size: 12px;
        }
        
        .jdt .content2 {
            position: absolute;
            right: 3px;
            top: 0;
            font-size: 12px;
        }    
        a {
            display: block;
            width: 200px;
            height: 30px;
            background-color: red;
            text-align: center;
            line-height: 30px;
            text-decoration: none;
            border: none;
            color: #fff;
            /* 块级盒子水平居中对齐 */
            margin: 5px auto;
        }
    </style>
</head>
  1. 注意事项
  • 在布局的时候我们可以先给每个模块添加背景颜色,方便布局,等布局完成之后再删去
  • 要牢记常见的水平/垂直居中对齐的方法
  • 代码应该还可以进一步简化的 这是最最最原始的一步步抠出来的代码~

最终效果

在这里插入图片描述
大概样子做出来就是这样啦~ 实际效果中的进度条当鼠标移动过去,还会变的哦~

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值