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

<!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模块/浮动与定位 138楼
WEB前端全系列/第一阶段:HTML5+CSS3模块/CSS常用属性 139楼
WEB前端全系列/第一阶段:HTML5+CSS3模块/表单 140楼

<!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常用属性 141楼
WEB前端全系列/第一阶段:HTML5+CSS3模块/CSS常用属性 142楼
WEB前端全系列/第一阶段:HTML5+CSS3模块/商城官网项目 144楼
WEB前端全系列/第一阶段:HTML5+CSS3模块/浮动与定位 145楼

<body>
    <table align="center">
        <tr>
            <td align="right">姓名:</td>
            <td>
                <input type="text">
            </td>
        </tr>
        <tr>
            <td align="right">密码:</td>
            <td>
                <input type="password">
            </td>
        </tr>
        <tr>
            <td align="right">确认密码:</td>
            <td>
                <input type="password">
            </td>
        </tr>
        <tr>
            <td align="right">密码提示问题:</td>
            <td>
                <select name="" id="">
                    <option value="">请选择一个问题</option>
                    <option value="">问题1-----</option>
                    <option value="">问题2-----</option>
                    <option value="">问题3-----</option>
                </select>
            </td>
        </tr>
        <tr>
            <td align="right">密码提示答案:</td>
            <td>
                <input type="text">
            </td>
        </tr>
        <tr>
            <td align="right">性别:</td>
            <td>
                <input type="radio" name="sex" value="男">男
                <input type="radio" name="sex" value="女">女
            </td>
        </tr>
        <tr>
            <td align="right">年龄:</td>
            <td>
                <input type="number" min="1" max="150">
            </td>
        </tr>
        <tr>
            <td align="right">籍贯:</td>
            <td>
                <select name="" id="">  
                    <option value="">请选择</option>
                    <option value="">甘肃</option>
                    <option value="">江苏</option>
                    <option value="">陕西</option>
                </select>省/直辖市
                <select name="" id="">请选择
                    <option value="">兰州</option>
                    <option value="">苏州</option>
                    <option value="">宝鸡</option>
                </select>市
            </td>
        </tr>
        <tr>
            <td align="right">爱好:</td>
            <td>
                <input type="checkbox" name="love" value="上网">上网
                <input type="checkbox" name="love" value="看电影">看电影
                <input type="checkbox" name="love" value="学习">学习

            </td>
        </tr>
        <tr>
            <td align="right">个人介绍:</td>
            <td>
                <textarea cols="30" rows="5"></textarea>
            </td>
        </tr>
        <tr>
            <td align="right">上传头像:</td>
            <td>
                <input type="file">
            </td>
        </tr>
        <tr align="center">
            <td colspan="2">
                <input type="submit" value="确认提交">
                <input type="reset" value="重新输入">
            </td>
        </tr>
    </table>
</body>

按钮想生效,不得用form把整个表格放到里面去吗,

为啥只有我提交的代码时黑白的~~~

image.png

WEB前端全系列/第一阶段:HTML5+CSS3模块/表单 146楼

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>渐变动画</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        body {
            display: flex;
            justify-content: left;
            align-items: center;
            width: 100%;
            height: 100vh;
            background-image: linear-gradient(135deg, #99ccff, #9999ff, #cc66ff);
            position: relative;   /*子元素都将相对于body定位*/
        }

        .box {
            width: 50px;
            height: 300px;
            background-image: linear-gradient(135deg, #66ffff, #66ccff, #6699ff);
            border-radius: 0 30px 30px 0;
            opacity: 0.4;
            transition: all 0.6s ease; /*侧边栏由透明变成有色并且伸展的效果动画时间*/
            position: absolute; 
            left: 200px   /*侧边栏将相对于body进行一个相对定位,据左边200px*/
        }

        ul {
            display: flex;
            height: 300px; /*给ul设定一个高度与容器高度一样,才可设置上下居中*/
            flex-direction: column;
            align-items: left;
            justify-content: center;
            padding-left: 25px;
            list-style: none;
            position: absolute; /*子元素都将相对于body定位*/
            left:200px ;  /*无序列表ul每个元素都将相对于body进行一个相对定位,据左边200px*/
            opacity: 0;
            transition: all 0.6s ease 0.6s;
        }

        ul li {
            margin: 12px 1px;
            
            /* display: none; */
            
        }

        ul li a{
            text-decoration: none ;
            color: white;
            text-shadow: -5px 5px 15px #bd4be3;
            font-size: 20px;
            font-weight: 700;
            
        }

        .t-box{
            width: 20px;
            height: 20px;
            border-radius: 50%;
            background-image: linear-gradient(135deg, #66ffff, #66ccff, #6699ff);
            margin-top: 20px;
            position: absolute;
            top: 160px;
            left: 200px;
        }

        .t-box:hover+.box{
            opacity: 1;
            width: 100px;
            height: 300px;
        }

        /* 在鼠标接触到的时候t-box的时候使其相邻兄弟元素box拉伸 */

       .t-box:hover~ul{
            
            opacity: 1;
       }

       
        
    </style>
</head>

<body>
    <div class="t-box"></div>
    <div class="box"></div>
    <ul>
        <li><a href="#">Play</a></li>
        <li><a href="#">Store</a></li>
        <li><a href="#">Map</a></li>
        <li><a href="#">Chart</a></li>
        <li><a href="#">Art</a></li>

    </ul>

   
</body>

</html>

如上做了一个丝滑的伸缩侧边栏,字体动画在栏伸展开之后才显示。问题是放开鼠标之后栏缩回去的时候,字体没有立刻消失,而是过了一会儿才消失。怎样设置才能让字体消失的时候也和菜单栏一起同一时间小时呢?

WEB前端全系列/第一阶段:HTML5+CSS3模块/CSS3新特性 147楼
WEB前端全系列/第一阶段:HTML5+CSS3模块/HTML5基础元素 150楼

课程分类

百战程序员微信公众号

百战程序员微信小程序

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