基于CSS的淘宝焦点图布局制作案例

分析:
    1. 大盒子我们类名为:tb-promo  淘宝广告;
    2. 里面先放一张图片;
    3. 左右两个按钮用键接,左箭头用prev    右箭头用next;
    4. 底侧小圆点用ul做,类名为promo-nav
 

<!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">
    <title>Document</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        li {
            list-style: none;
        }

        .tb-promo {
            position: relative;
            /* position: relative;孩子有绝对定位,父亲要设置成相对定位,子绝父相 */
            width: 1080px;
            height: 720px;
            margin: 30px auto;
        }

        .tb-promo img {
            width: 1080px;
            height: 720px;
        }

        .tb-promo a {
            text-decoration: none;
        }

        .prev,
        .next {
            position: absolute;
            /* position: absolute;加了绝对定位的盒子可以直接设置宽度和高度,会覆盖其他元素*/

            /* 绝对定位的盒子垂直居中: */
            top: 50%;
            margin-top: -15px;


            width: 25px;
            height: 40px;
            background: rgb(0, 0, 0, 0.4);
            text-align: center;
            line-height: 40px;
            color: white;
        }

        .prev {
            left: 0;

            /* 设置圆角: */
            border-top-right-radius: 15px;
            border-bottom-right-radius: 15px;
        }

        .next {
            right: 0;

            /* 设置圆角: */
            border-top-left-radius: 15px;
            border-bottom-left-radius: 15px;
        }

        .promo-nav {
            position: absolute;
            bottom: 15px;

            /* 水平居中效果等同于 left: 505px; */
            left: 50%;
            margin-left: -35px;

            width: 70px;
            height: 13px;
            background-color: rgb(255, 255, 255, 0.4);
            border-radius: 7px;
            /* border-radius: 7px;将圆角设置为高度的一半 */
        }

        .promo-nav li {
            float: left;
            width: 8px;
            height: 8px;
            background-color: white;
            border-radius: 50%;
            margin: 3px;
        }

        /* 权重高的会重叠权重低的的样式,类选择器权重为10,标签权重为1 */
        .promo-nav .selected {
            background-color: gray;
        }
    </style>
</head>

<body>
    <div class="tb-promo">
        <img src="./images/tb.jpg" alt="">

        <!-- 左按钮开始 -->
        <a href="#" class="prev"> &lt; </a>
        <!-- 左按钮结束 -->

        <!-- 右按钮开始 -->
        <a href="#" class="next"> &gt; </a>
        <!-- 右按钮结束 -->

        <!-- 小圆点开始 -->
        <ul class="promo-nav">
            <li class="selected"></li>
            <li></li>
            <li></li>
            <li></li>
            <li></li>
        </ul>
        <!-- 小圆点结束 -->
    </div>
</body>

</html>

 

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值