会员可以在此提问,百战程序员老师有问必答
对大家有帮助的问答会被标记为“推荐”
看完课程过来浏览一下别人提的问题,会帮你学得更全面
截止目前,同学们一共提了 134250个问题
WEB前端全系列/第一阶段:HTML5+CSS3模块/CSS应用技巧 136楼
WEB前端全系列/第一阶段:HTML5+CSS3模块/表单 142楼

<!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>
        .nav{
            width: 100%;
            height: 60px;
            background-color: black;
        }

        .nav ul{
            overflow: hidden;
            clear: both;
        }

        .nav ul li{
            list-style: none;
            float: left;
            padding: 20px 25px;
        }

        .nav ul li a{
            color: aqua;
            text-decoration: none;
            font-size: 30px;
        }
        .box{
            width: 100%;
            height: 300px;
            position: absolute;
            left: 0%;
            display:none;
        }

        .nav li:hover>.box{
            display: block;
        }


    </style>

</head>
<body>
   
    <div class="nav">
        <ul>
            <li><a href="#">首页</a>    
            <div class="box" style="background-color: red;"></div><!--这个就是下拉列代表的容器-->
        </li>
            <li><a href="#">手机</a>    
            <div class="box" style="background-color: gold;"></div>
        </li>


            <li><a href="#">配件</a>    
            <div class="box" style="background-color: green;"></div>
        </li>

            <li><a href="#">电脑</a>    
            <div class="box" style="background-color: blanchedalmond;"></div>
        </li>
            <li><a href="#">手表</a>    
            <div class="box" style="background-color: blue;"></div>
        </li>
        </ul>
    </div>

</body>
</html>


WEB前端全系列/第一阶段:HTML5+CSS3模块/浮动与定位 143楼
WEB前端全系列/第一阶段:HTML5+CSS3模块/CSS常用属性 144楼
WEB前端全系列/第一阶段:HTML5+CSS3模块/表单 145楼

<!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>
    <link rel="stylesheet" href="css1/reset.css">
    <style>
        .box{
            box-sizing: border-box;
            width: 234px;
            height: 320px;
            padding: 20px 0;
            position: relative;
            text-align: center;
            background-color: coral;
            margin: 10px;
        }
        .box img{
            width: 80px;
            height: 160px;
            position: absolute;
            top: 21px;
            left: 77px;


        }
        .box>img:first-child{
            z-index: 10;
        }
        .box2{
            position: absolute;
            top:204px;
            background-color: yellow;
            width: 100%;
            height: 102px;
            text-align: center;
        }
        p{margin-bottom: 1px ;
      }
      .box2>p:last-child{
          margin-top: 10px;
      }

      .box:hover>img:first-child{
          left:40px
      }
      .box:hover>img:last-child{
       left:114px
      }
    </style>
</head>
<body>
   
<div class="box">
    <img src="images/position练习3.jpg" alt="">
    <img src="images/22.jpg" alt="" class="i2">
       <div class="box2">
          <p>黑鲨4S</p>
          <p>磁动力升降肩键</p>
          <p>2699元起</p>

    </div>
</div>
</body>
</html>

老师为啥用这个 last-child选择器不生效  用类选择器.i2就会生效?  要有三个img才可以使用last-child嘛?

.box:hover>img:last-child{
       left:114px
      }


WEB前端全系列/第一阶段:HTML5+CSS3模块/CSS常用属性 146楼
WEB前端全系列/第一阶段:HTML5+CSS3模块/CSS常用属性 147楼
WEB前端全系列/第一阶段:HTML5+CSS3模块/商城官网项目 149楼
WEB前端全系列/第一阶段:HTML5+CSS3模块/浮动与定位 150楼

课程分类

百战程序员微信公众号

百战程序员微信小程序

©2014-2025百战汇智(北京)科技有限公司 All Rights Reserved 北京亦庄经济开发区科创十四街 赛蒂国际工业园
网站维护:百战汇智(北京)科技有限公司
京公网安备 11011402011233号    京ICP备18060230号-3    营业执照    经营许可证:京B2-20212637