CSS几个练习

在这里插入图片描述

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <link rel="stylesheet" href="../reset.css">
    <style>
        body{
            background-color: rosybrown;
        }
        ul{
            width: 200px;
            height: 500px;
            /* 裁剪 */
            overflow: hidden;
            margin: 50px auto;
        }
        /* .img-list li{
             margin-bottom: 10px;
        } */
         .img-list li:not(:last-child){
             margin-bottom: 10px;
        }
        .img-list img{
            width: 196px;
            /* 高度自适应 */
            border: black 2px solid;
           
        }
    </style>


</head>
<body>
    <ul class="img-list">
        <li><a href="javascript:;"><img src="../IMG/1.png" alt=""></a></li>
        <li><a href="javascript:;"><img src="../IMG/2.png" alt=""></a></li>
        <li><a href="javascript:;"><img src="../IMG/3.png" alt=""></a></li>
    </ul>
</body>
</html>

在这里插入图片描述

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <style>
        body{
            background-color: rgb(153, 182, 236);
        }
        .left-nav{
            width: 200px;
            height: 450px;
            padding:10px 0;
            background-color: white;
            margin:50px auto;
        }
        .left-nav .item{
             /* 要让一个文字在父元素中垂直居中,只需将父元素的line-height设置为和父元素的height一样的值 */
            height: 25px;
            line-height: 25px;

            padding-left: 18px;
        }
        .left-nav .item:hover{
    
            background-color: rgb(209, 209, 209);
        }
        .item a{
            color:#333;
            text-decoration: none;
            font-size: 14px;
        }
        .item a:hover{
            color: red;
        }
        span{
            font-size: 10px;
            color: rgb(92, 92, 92);
            padding: 3px;
        }

    </style>
</head>
<body>
    <nav class="left-nav">
         <div class="item"><a href="#">家用电器</a></div>
         <div class="item">
             <a href="#">手机</a><span>/</span>
             <a href="#">运营商</a><span>/</span>
             <a href="#">数码</a>
         </div>
         <div class="item">
             <a href="#">电脑</a><span>/</span>
             <a href="#">办公</a>
         </div>
         <div class="item">
             <a href="#">男鞋</a><span>/</span>
             <a href="#">女鞋</a>
         </div>
         <div class="item">
             <a href="#">家具</a><span>/</span>
             <a href="#">家居</a><span>/</span>
             <a href="#">家装</a><span>/</span>
             <a href="#">厨具</a>
         </div>
         <div class="item"><a href="#">家用电器</a></div>
         <div class="item">
             <a href="#">手机</a><span>/</span>
             <a href="#">运营商</a><span>/</span>
             <a href="#">数码</a>
         </div>
         <div class="item">
             <a href="#">电脑</a><span>/</span>
             <a href="#">办公</a>
         </div>
         <div class="item">
             <a href="#">男鞋</a><span>/</span>
             <a href="#">女鞋</a>
         </div>
         <div class="item">
             <a href="#">家具</a><span>/</span>
             <a href="#">家居</a><span>/</span>
             <a href="#">家装</a><span>/</span>
             <a href="#">厨具</a>
         </div>
                  <div class="item"><a href="#">家用电器</a></div>
         <div class="item">
             <a href="#">手机</a><span>/</span>
             <a href="#">运营商</a><span>/</span>
             <a href="#">数码</a>
         </div>
         <div class="item">
             <a href="#">电脑</a><span>/</span>
             <a href="#">办公</a>
         </div>
         <div class="item">
             <a href="#">男鞋</a><span>/</span>
             <a href="#">女鞋</a>
         </div>
         <div class="item">
             <a href="#">家具</a><span>/</span>
             <a href="#">家居</a><span>/</span>
             <a href="#">家装</a><span>/</span>
             <a href="#">厨具</a>
         </div>
         <div class="item"><a href="#">家用电器</a></div>
         <div class="item">
             <a href="#">手机</a><span>/</span>
             <a href="#">运营商</a><span>/</span>
             <a href="#">数码</a>
         </div>
         <div class="item">
             <a href="#">电脑</a><span>/</span>
             <a href="#">办公</a>
         </div>
    </nav>
    
</body>
</html>

在这里插入图片描述

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <title>网易新闻列表</title>
    <link rel="stylesheet" href="../reset.css">
    <style>
        body{
             background-color: rosybrown;
        }
        a{
             text-decoration: none;
        }
        .news{
            width: 300px;
            height: 548px;
            background-color: whitesmoke;
            margin: 50px auto;
            border-top:2px solid rgb(184, 184, 184) ;
        }
        .news-title{
            display: inline-block;
            height: 40px;
            border-top: 2px red solid;
            margin-top:  -2px;
            padding-top: 10px;
        }
        .news-title a{
            color:black;
            /*设置文字加粗效果 */
            font-weight: bold;

        }
        .news-img{
            height: 300px;

        }
        .news-img .img-title{
            /* width: 150px; */
            margin-top: -30px;
            color: black; 
            font-weight: bold;
            /* margin-right: auto;
            margin-left: auto;       */
        }
        .news-img a{
            /* 居中 */
           text-align: center;
        }

        .news-list{
            margin-top: 20px;
            padding-left: 14px;
        }
        .news-list li{
            margin-bottom: 17px;
        }
        .news-list li a{
            font-size: 14px;
            color: #666;
        }
        .news-list li a:hover{
            color: red;
        }

        .news-list li::before{
            content: '■';
            color: rgb(214, 214, 214);
            font-size: 12px;
            margin-right: 3px;
        }
    </style>
  </head>
  <body>
    <div class="news">
      <h2 class="news-title"><a href="#">体育</a></h3>
      <div class="news-img">
        <a href="#">
          <img src="../IMG/4.jpg" alt="篮球" />
          <h3 class="img-title">李宁 吸湿PU 篮球</h3>
        </a>
      </div>
      <ul class="news-list">
        <li><a href=""> PU材质,防滑耐磨。</a></li>
        <li>
          <a href="">
            这款篮球采用PU材质,具有良好的防滑性,让你轻松应对各种场地。
          </a>
        </li>
        <li><a href=""> 另外,搭载防滑耐磨的中胎,能够有效的减少漏气</a></li>
        <li><a href=""> 让你的运动更加的安全</a></li>
      </ul>
    </div>
  </body>
</html>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值