模仿淘宝的焦点图【前端基础】

 黑马程序员pink老师html、css入门教学【参考视频】icon-default.png?t=M4ADhttps://www.bilibili.com/video/BV14J4114768?p=243

今天要模仿的是,淘宝界面的焦点图,如下图所示:

 

代码部分 

<!DOCTYPE html>
<html lang="zh-CN">
<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">
    <title>淘宝焦点图</title>
    <style>

        * {
            margin: 0;
            padding: 0;
        }

        li {
            list-style: none;
        }

        /* 焦点图 */
        .promo{
            position: relative;
            width: 564px;
            height: 315px;
            border-radius: 12px;
            margin: 100px auto;
        }

        /* 设置背景图片 */
        .promo img {
            display: block;
            width: 564px;
            height: 315px;
            border-radius: 12px;
        }

        /* 设置箭头 */
        .promo .prev,
        .promo .next {
            position: absolute;
            width: 20px;
            height: 30px;
            background-color: rgba(0,0,0,.3);
            
            top: 158px;

            color: #fff;
            font-size: 14px;
            line-height: 30px;
            text-align: center;
        }

        /* 设置左箭头 */
        .promo .prev {
            left: 0;

            border-top-right-radius: 15px;
            border-bottom-right-radius: 15px;
        }

        /* 设置右箭头 */
        .promo .next {
            right: 0;

            border-top-left-radius: 15px;
            border-bottom-left-radius: 15px;      
        }

        /* 小圆点导航栏 */
        .promo .promo-nav {
            position: absolute;
            width: 70px;
            height: 13px;
            background-color: rgba(255, 255, 255, 0.3);

            left: 50%;
            margin-left: -39px;
            bottom: 15px;

            border-radius: 10px;
            
        }

        .promo li a{
            float: left;
            display: block;
            width: 8px;
            height: 8px;
            background-color: #fff;
            
            border-radius: 50%;
            margin: 3px;

        }

        .promo .selected {
            background-color: #ff5000;
        }

    </style>
</head>
<body>
    <div class="promo">
        <!-- 背景图片 -->
        <img src="https://img.alicdn.com/imgextra/i4/6000000004579/O1CN01oy4rU41jhELINMKkT_!!6000000004579-2-octopus.png" alt="">
        <!-- 左箭头 -->
        <div class="prev">&lt;</div>
        <!-- 右箭头 -->
        <div class="next">&gt;</div>
        <!-- 小圆点 -->
        <div class="promo-nav">
            <li><a href="#" class="selected"></a></li>
            <li><a href="#"></a></li>
            <li><a href="#"></a></li>
            <li><a href="#"></a></li>
            <li><a href="#"></a></li>
        </div>
    </div>
</body>
</html>

 效果截图

 

 

posted @ 2022-05-21 20:45  辰梦starDream  阅读(8)  评论(0编辑  收藏  举报  来源