css 笔记2

本文详细介绍了HTML中的超链接伪类选择器,包括hover状态下的颜色变化、active状态的行为以及visited状态的显示效果。此外,还展示了如何运用CSS控制列表样式、背景、渐变、边框和圆角等元素。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

超链接伪类选择器

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
  <style>
    a{
      text-decoration: none;
      color:#000000;
    }
    /*鼠标悬浮的颜色*/
    a:hover{
      color:orange;
      font-size:50px;
    }
    /*鼠标按住未放开的状态*/
    a:active{
      color:green;
    }
    /*点击后*/
    a:visited{
      color:red;
    }
    #author{
      text-shadow: #114ed0 10px 10px 2px;/*阴影颜色 水平偏移 垂直偏移 阴影半径*/
    }
  </style>
</head>
<body>
<a href="#">
  <img src="images/11..png">
</a>
<p>
  <a href="#">海贼王</a>
</p>
<p>
  <a href="" id="author">尾田</a>
</p>
</body>
</html>

列表样式练习

#nav{
    width:300px;
    background: #a0a0a0;
}
.title{
    font-size: 18px;
    font-weight: bold;
    text-indent:2em;
    line-height: 30px;
    background: red;
}
/*none 去掉圆点
circle 空心圆
decimal 数字
square 正方形
*/
ul{
    background: #a0a0a0;
}
ul li{
    height:30px;
    list-style: none;
    text-indent:2em;
}
a{
    text-decoration: none;
    font-size: 14px;
    color:#000;
}
a:hover{
    color:orange;
    text-decoration: underline;
}
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
  <link href="style.css" rel="stylesheet" type="text/css">
</head>
<body>
<body>
<div id="nav">
  <h2 class="title">全部商品分类</h2>

  <ul>
    <li>
      <a href=" ">图书</a>
      <a href="#">音像</a>
      <a href="#">数字商品</a>
    </li>
    <li>
      <a href="#">家用电器</a>
      <a href="#">手机</a>
      <a href="#">数码</a>
    </li>
    <li>
      <a href="#">电脑</a>
      <a href="#">办公</a>
    </li>
    <li>
      <a href="#">家居</a>
      <a href="#">家装</a>
      <a href="#">厨具</a>
    </li>
    <li>
      <a href="#">服饰鞋帽</a>
      <a href="#">个性化妆</a>
    </li>
    <li>
      <a href="#">礼品箱包</a>
      <a href="#">钟表</a>
      <a href="#">珠宝</a>
    </li>
    <li>
      <a href="#">食品饮料</a>
      <a href="#">保健食品</a>
    </li>
    <li>
      <a href="#">彩票</a>
      <a href="#">旅行</a>
      <a href="#">充值</a>
      <a href="#">票务</a>
    </li>
  </ul>
</div>


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

背景

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
  <style>
    /*background 颜色 图片  图片位置  平铺方式*/
    div{
      width:1000px;
      height:700px;
      border:1px solid red;
      background-image: url("images/11..png");/*默认是全部平铺的*/
    }
    .div1{
      background-repeat: repeat-x;
    }
    .div2{
      background-repeat: repeat-y;
    }
    .div3{
      background-repeat: no-repeat;
    }
  </style>
</head>
<body>
<div class="div1"></div>
<div class="div2"></div>
<div class="div3"></div>
</body>
</html>

渐变

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
  <style>
    body {
      background-image: linear-gradient(91deg, #4158D0 0%, #C850C0 46%, #FFCC70 100%);

    }
  </style>
</head>
<body>

</body>
</html>

盒子

margin:外边距
padding:内边距
border:边框
边框

  1. 边框的粗细
  2. 边框的样式
  3. 边框的颜色
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>

    <style>
        /*h1,ul,li,a,body{*/
        /*    margin:0;*/
        /*    padding:0;*/
        /*    text-decoration: none;*/
        /*}*/
        /*border:粗细 样式 颜色  solid 实线
        body 默认有8的margin
        */
        #box{
            width:300px;
            border: 1px solid red;
        }
        h2{
            font-size: 16px;
            background: #C850C0;
            line-height: 35px;
            margin:0;
        }
        form{
            background: #114ed0;
        }
        div:nth-of-type(1) input {
            border:3px solid black;
        }
        div:nth-of-type(2) input {
            border:3px dashed green;
        }
    </style>
</head>
<body>
<div id="box">
  <h2>会员登陆</h2>
    <form action="#">
        <div>
            <span>用户名:</span>
            <input type="text">
        </div>
        <div>
            <span>密码:</span>
            <input type="text">
        </div>
        <div>
            <span>邮箱:</span>
            <input type="text">
        </div>
    </form>
</div>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>

    <style>
        /*h1,ul,li,a,body{*/
        /*    margin:0;*/
        /*    padding:0;*/
        /*    text-decoration: none;*/
        /*}*/
        /*border:粗细 样式 颜色  solid 实线
        body 默认有8的margin
        */

        /*外边距的妙用:居中  顺时针旋转*/
        #box{
            width:300px;
            border: 1px solid red;
            margin:0 auto ;
        }
        h2{
            font-size: 16px;
            background: #C850C0;
            line-height: 35px;
            margin:0;
        }
        form{
            background: #114ed0;
        }
        input{
            border:1px solid black ;
        }
        form div:nth-of-type(1){
            padding:10px;
        }
    </style>
</head>
<body>
<div id="box">
  <h2>会员登陆</h2>
    <form action="#">
        <div>
            <span>用户名:</span>
            <input type="text">
        </div>
        <div>
            <span>密码:</span>
            <input type="text">
        </div>
        <div>
            <span>邮箱:</span>
            <input type="text">
        </div>
    </form>
</div>
</body>
</html>

圆角边框

4个角

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>

  <style>
    img{
      /*border-radius 左上:上 右上:右 右下:下 左下:左*/
        height:200px;
        width:200px;
        border-radius:50px;
      box-shadow: 10px 10px 100px yellow;
    }
  </style>

</head>
<body>

<div style="width: 1000px ;display: block; text-align: center">
        <img src="images/11..png" alt="">
</div>


</body>
</html>

display和浮动

标准文档流:自上而下的默认效果
块级元素 独占一行:h1-h6 p div 列表
行内元素 不独占一行 :span a img strong
行内元素可以被包含在块级元素中,反之,则不可以~

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
  <style>
      /*block 块元素
      inline 行内元素
      inline-block ,是块元素,但是可以在一行
      none 消失
      */
    div{
      width:100px;
      height:100px;
      border:1px solid red;
        display: inline;
    }
    span{
      width:100px;
      height:100px;
      border:1px solid red;
        display: inline-block;
    }
  </style>
</head>
<body>
<div>div块元素</div>
<span>span行内元素</span>
</body>
</html>

阴影

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>

  <style>
    img{
      /*border-radius 左上:上 右上:右 右下:下 左下:左*/
        height:200px;
        width:200px;
        border-radius:50px;
      box-shadow: 10px 10px 100px yellow;
    }
  </style>

</head>
<body>

<div style="width: 1000px ;display: block; text-align: center">
        <img src="images/11..png" alt="">
</div>


</body>
</html>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

三粒小金子

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值