CSS自学Day10- (项目案例)小兔鲜儿小主体部分

目录

新鲜好物-内容完成

新鲜好物-新品文字

生鲜标题-布局

生鲜区域

生鲜-内容-布局


效果图:

index.html:

    <!-- banner -->
    <div class="banner">
        <div class="wrapper">
            <!-- 有多少张图,就放多少个li -->
            <ul>
                <li><a href="#"><img src="./uploads/banner_1.png" alt=""></a></li>
            </ul>
        </div>
    </div>

index.css:

.banner{
    height: 500px;
    background-color: #f5f5f5;
}

.banner .wrapper{
    height: 500px;
    background-color: pink;
}


效果图:

index.html:

          <!-- 侧导航 -->
            <div class="aside">
                <ul>
                    <li><a href="#">生鲜<span>水果 蔬菜</span></a></li>
                    <li><a href="#">生鲜<span>水果 蔬菜</span></a></li>
                    <li><a href="#">生鲜<span>水果 蔬菜</span></a></li>
                    <li><a href="#">生鲜<span>水果 蔬菜</span></a></li>
                    <li><a href="#">生鲜<span>水果 蔬菜</span></a></li>
                    <li><a href="#">生鲜<span>水果 蔬菜</span></a></li>
                    <li><a href="#">生鲜<span>水果 蔬菜</span></a></li>
                    <li><a href="#">生鲜<span>水果 蔬菜</span></a></li>
                    <li><a href="#">生鲜<span>水果 蔬菜</span></a></li>
                    <li><a href="#">生鲜<span>水果 蔬菜</span></a></li>
                </ul>
            </div>

index.css:

/* 侧导航 */
.banner .aside{
    position: absolute;
    left: 0;
    top: 0;
    width: 250px;
    height: 500px;
    background-color: rgba(0,0,0,0.8);
}

.banner .aside li{
    height: 50px;
    line-height: 50px;
}

.banner .aside a{
    /* 宽度和父级一样 */
    display: block;
    padding-left: 36px;
    padding-right: 19px;
    width: 250px;
    height: 50px;
    background-color: pink;
}


效果图:

index.html:

     <!-- 侧导航 -->
            <div class="aside">
                <ul>
                    <li><a href="#">生鲜<span>水果 蔬菜</span></a></li>
                    <li><a href="#">生鲜<span>水果 蔬菜</span></a></li>
                    <li><a href="#">生鲜<span>水果 蔬菜</span></a></li>
                    <li><a href="#">生鲜<span>水果 蔬菜</span></a></li>
                    <li><a href="#">生鲜<span>水果 蔬菜</span></a></li>
                    <li><a href="#">生鲜<span>水果 蔬菜</span></a></li>
                    <li><a href="#">生鲜<span>水果 蔬菜</span></a></li>
                    <li><a href="#">生鲜<span>水果 蔬菜</span></a></li>
                    <li><a href="#">生鲜<span>水果 蔬菜</span></a></li>
                    <li><a href="#">生鲜<span>水果 蔬菜</span></a></li>
                </ul>
            </div>

index.css:

.banner .aside a{
    position: relative;
    /* 宽度和父级一样 */
    padding-left: 36px;
    padding-right: 19px;
    display: block;
    height: 50px;
    /* background-color: pink; */
    color: #fff;
}

.bannner .aside span{
    margin-left: 15px;
    font-size: 14px;
}

.banner .aside a:hover{
    color: #27ba9b;
}

/* 在a的里面的最后的位置添加箭头 */
.banner .aside a::after{
    position: absolute;
    right: 19px;
    top: 19px;
    content: '';
    width: 6px;
    height: 11px;
    background-image: url(../images/sprites.png);
    background-position: -80px -110px;
    background-color: green;
}

效果图:

html:

<!-- 箭头 -->
            <!-- prev:上一个 -->
            <a href="#" class="prev"></a>
            <!-- next:下一个 -->
            <a href="" class="next"></a>

css:


/* 箭头 */
.prev,
.next{
    position: absolute;
    top: 228px;
    width: 45px;
    height: 45px;
    background-color: rgba(0,0,0,.2);
    background-image: url(../images/sprites.png);
    border-radius: 50%;
}

/* 背景图位置负责两件事:改变箭头在盒子里的位置;改变精灵图的位置 */
/* 导致在精灵图中测量不准确 */
/* 解决方案:1.书写背景图位置属性,借助谷歌调试工具调试具体的位置数值
            2.书写标签的时候,a负责盒子,span负责图案
 */

.prev{
    left: 260px;
    background-position: 14px -60px;
}

.next{
    right: 10px;
    background-position: -24px -60px;
}

效果图:

html:


            <!-- 圆点:当前状态:current/active -->
            <!-- js找到用户当前的li 添加类名 li变成白色的 -->
            <ol>
                <li></li>
                <li></li>
                <li class="current"></li>
                <li></li>
                <li></li>
            </ol>

css:

/* 圆点 */
.banner ol{
    position: absolute;
    left: 680px;
    bottom: 30px;
    /* width: 200px; */
    height: 10px;
    /* background-color: pink; */
}

.banner ol li{
    float: left;
    margin-right: 24px;
    width: 10px;
    height: 10px;
    background-color: rgba(255,255,255,0.4);
    border-radius: 50%;
    cursor: pointer;
}

.banner ol .current{
    background-color: #fff;
}

新鲜好物-标题

效果图:

html:

   <!-- 新鲜好物 -->
    <div class="goods wrapper">
        <!-- hd header,头部 -->
        <div class="hd">
            <h2>新鲜好物<span>新鲜出炉 品质靠谱</span></h2>
            <a href="#">查看全部</a>
        </div>
        <!--body 身体,内容 -->
        <div class="bd"></div>
    </div>

css: 

/* 新鲜好物 */
.goods .hd{
    height: 114px;
    /* background-color: pink; */
    line-height: 114px;
}

.goods .hd h2{
    float: left;
    font-size: 29px;
    font-weight: 400;
    height: 114px;
}

.goods .hd h2 span{
    margin-left: 34px;
    font-size: 16px;
    color:#999;
}
.goods .hd a{
    float: right;
    color: #999;
}

.goods .hd a::after{
    display: inline-block;
    margin-left: 13px;
    content: '';
    width: 7px;
    height: 13px;
    /* background-color: green; */
    background-image: url(../images/sprites.png);
    background-position: 0 -110px;
}

新鲜好物-内容-布局

效果图:

html:

     <!--body 身体,内容 -->
        <div class="bd clearfix">
            <ul>
                <li></li>
                <li></li>
                <li></li>
                <li></li>
        </ul>
        </div>

css:

/* 新鲜好物 */
.goods .hd{
    height: 114px;
    /* background-color: pink; */
    line-height: 114px;
}

.goods .hd h2{
    float: left;
    font-size: 29px;
    font-weight: 400;
    height: 114px;
}

.goods .hd h2 span{
    margin-left: 34px;
    font-size: 16px;
    color:#999;
}
.goods .hd a{
    float: right;
    color: #999;
}

.goods .hd a::after{
    display: inline-block;
    margin-left: 13px;
    content: '';
    width: 7px;
    height: 13px;
    /* background-color: green; */
    background-image: url(../images/sprites.png);
    background-position: 0 -110px;
}

.goods .bd li{
    margin-right: 8px;
    float: left;
    width: 304px;
    height: 405px;
    background-color: #f0f9f4;
}

.goods .bd li:last-child{
    margin-right: 0;
}

新鲜好物-内容完成

效果图:

html:

        <!--body 身体,内容 -->
        <div class="bd clearfix">
            <ul>
                <li>
                    <img src="./uploads/new_goods_1.jpg" alt="">
                    <h3>睿米无线吸尘器F8</h3>
                    <div>¥ <span>899</span></div>
                </li>
                <li>
                    <img src="./uploads/new_goods_1.jpg" alt="">
                    <h3>睿米无线吸尘器F8</h3>
                    <div>¥ <span>899</span></div>
                </li>
                <li>
                    <img src="./uploads/new_goods_1.jpg" alt="">
                    <h3>睿米无线吸尘器F8</h3>
                    <div>¥ <span>899</span></div>
                </li>
                <li>
                    <img src="./uploads/new_goods_1.jpg" alt="">
                    <h3>睿米无线吸尘器F8</h3>
                    <div>¥ <span>899</span></div>
                </li>
        </ul>
        </div>

css:

.goods .bd li img{
    width: 304px;
}

.goods .bd li h3{
    margin-top: 20px;
    margin-bottom: 10px;
    font-size: 20px;
    font-weight: 400;
}

.goods .bd li div{
    color: #9a2e1f;
    font-size: 17px;

}

.goods .bd li span{
    font-size: 23px;
}

新鲜好物-新品文字

效果图:

html:

    <ul>
                <li>
                    <img src="./uploads/new_goods_1.jpg" alt="">
                    <h3>睿米无线吸尘器F8</h3>
                    <div>¥ <span>899</span></div>
                    <b>新品</b>
                </li>
                <li>
                    <img src="./uploads/new_goods_1.jpg" alt="">
                    <h3>睿米无线吸尘器F8</h3>
                    <div>¥ <span>899</span></div>
                    <b>新品</b>
                </li>
                <li>
                    <img src="./uploads/new_goods_1.jpg" alt="">
                    <h3>睿米无线吸尘器F8</h3>
                    <div>¥ <span>899</span></div>
                    <b>新品</b>
                </li>
                <li>
                    <img src="./uploads/new_goods_1.jpg" alt="">
                    <h3>睿米无线吸尘器F8</h3>
                    <div>¥ <span>899</span></div>
                    <b>新品</b>
                </li>
        </ul>

css:

.goods .bd li b{
    position: absolute;
    left: 17px;
    top: 18px;
    width: 28px;
    height: 51px;
    border: 1px solid #27ba9b;
    border-radius: 2px;
    font-size: 18px;
    color: #27ba9b;
    font-weight: 400;
    line-height: 24px;
}

生鲜标题-布局

效果图:

html:

    <!-- 生鲜 -->
    <div class="shengxian wrapper">
        <div class="hd">
            <h2>生鲜</h2>
            <a href="#" class="more">查看全部</a>
            <ul>
                <li><a href="#">水果</a></li>
            </ul>
        </div>
        <div class="bd"></div>
    </div>

css:

/* 生鲜 */
.shengxian .hd{
    height: 96px;
    background-color: pink;
    line-height: 96px;
}

.shengxian .hd h2{
    float: left;
}

.shengxian .hd .more{
   float: right;
}

.shengxian .hd ul{
    float: right;
}

生鲜区域

生鲜图:

html:

    <!-- 生鲜 -->
    <div class="shengxian wrapper">
        <div class="hd">
            <h2>生鲜</h2>
            <a href="#" class="more">查看全部</a>
            <ul>
                <li><a href="#">水果</a></li>
                <li><a href="#">水果</a></li>
                <li><a href="#">水果</a></li>
                <li><a href="#">水果</a></li>
                <li><a href="#">水果</a></li>
                <li><a href="#">水果</a></li>
                <li><a href="#">水果</a></li>
            </ul>
        </div>
        <div class="bd"></div>
    </div>

css:

.goods .hd a,
.shengxian .hd .more{
    float: right;
    color: #999;
}

.goods .hd a::after,
.shengxian .hd .more::after{
    display: inline-block;
    margin-left: 13px;
    content: '';
    width: 7px;
    height: 13px;
    /* background-color: green; */
    background-image: url(../images/sprites.png);
    background-position: 0 -110px;
}
.shengxian .hd ul{
    float: right;
    margin-right: 65px;
}
.shengxian .hd ul li{
    float: left;
}

.shengxian .hd li a{
    padding: 2px 7px;
    margin-left: 6px;
}

.shengxian .hd li a:hover{
    background-color:#27ba9b;
    color: #fff;
}

生鲜-内容-布局

效果图:

 html:       

   <div class="bd clearfix">
            <div class="left">
                <a href="#"><img src="./uploads/fresh_goods_cover.png" alt=""></a>
            </div>
            <div class="right"></div>
        </div>

css:

.shengxian .bd .left{
    float: left;
    width: 240px;
    height: 610px;
    background-color: pink;
}

.shengxian .bd .right{
    float: right;
    width: 1000px;
    height: 610px;
    background-color: skyblue;
}

  • 2
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

什么时候养猫猫

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值