html+css小案例(盒子排版,二级菜单)

目录

1.盒子用ps裁量案例

最后运行的效果为:

练习代码为:

2.二级菜单案例

练习结果为:

练习代码为:


1.盒子用ps裁量案例

最后运行的效果为:

练习代码为:

<!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;
        }

        img{
            /* 转换图片类型 图片和文字之间就没有缝隙了 */
            display: block;
        }

        #box{
            width: 241px;
            height: 335px;
            /* background: yellow; */
            margin: 0 auto;
            padding: 11px 11px 18px;
        }
        .title{
            width: 235px;
            height: 19px;
            /* background: red; */
            padding-left: 4px;
            border-left: 2px solid #254291;
            color: #254291;
            line-height: 19px;
            font-size: 14px;
            font-weight: bold;
            margin-bottom: 14px;

        }
        .bigpic{
            width: 241px;
            height: 170px;
            margin-bottom: 16px;
        }
        .bigpic p{
            width: 241px;
            height: 26px;
            background-color: #f6f7f8;
            font-size: 12px;
            text-align: center;
            line-height: 26px;
        }
        .smallpic{
            width: 241px;
            height: 120px;
        }
        .smallpic p {
            font-size: 12px;
            width: 112px;
            background-color: #f6f7f8;
            line-height: 18px;
        }
        .left{
            float: left;
        }
        .right{
            float: right;
        }
    </style>
</head>
<body>
    <div id="box">
        <div class="title">
            女人图片
        </div>
        <div class="bigpic">
            <img src="img/big.jpg" alt="大姐">
            <p>大姐利用废物联盟经营美容院</p>
        </div>
        <div class="smallpic">
            <div class="left">
                <img src="img/smill1.jpg" alt="图1">
                <p>无效化妆无效穿搭≠容貌焦虑</p>
            </div>
            <div class="right">
                <img src="img/smill2.jpg" alt="图2">
                <p>小个子不要怕!“高人一等”的穿搭给你</p>
            </div>
        </div>
    </div>
</body>
</html>

2.二级菜单案例

练习结果为:

 

练习代码为:

<!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>
        /* 
        选择器
        .item>ul  (>)亲儿子选择器
        .item ul  (空格)后代选择器
        */
        *{
            padding: 0;
            margin: 0;
        }
        .box{
            width: 300px;
            margin: 0 auto;
        }
        ul{
            list-style: none;
        }
        .box .item{
            float: left;
            width: 148px;
            text-align: center;
            line-height: 40px;
            border: 1px solid blue;
            background-color: blue;
            color: white;
            height: 40px;
        }
        .item:hover{
            background: lightblue;
        }
        .item ul{
            display: none;
            background: white;
            color: black;
        }
        .item:hover ul{
            display: block;
        }
        .item li:hover{
            color: blue;
        }
    </style>
</head>
<body>
    <ul class="box">
        <li class="item">视频教程
            <ul>
                <li>全部视频教程</li>
                <li>html5视频教程</li>
                <li>java视频教程</li>
                <li>python视频教程</li>
            </ul>
        </li>
        <li class="item">认证考试
            <ul>
                <li>pmp</li>
                <li>红帽</li>
            </ul>
        </li>
    </ul>
</body>
</html>

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值