复合选择器

### 1、伪类链接选择器

用于添加特殊效果

- 语法

```

    选择器:伪类{ }

```

- 用于设置链接的不同状态

```css

    a:link{ 链接的默认样式 }

    a:visited{ 链接访问过后的样式 }

    a:hover{ 鼠标悬停的样式 }

    a:active{ 鼠标按下的样式 }

   

    a:link {

            color: tomato;

        }

        a:visited {

            color: yellow;

        }

        a:hover {

            color: purple;

        }

        a:active {

            color: greenyellow;

        }

```

> 四个伪类状态都有效:L-v-H-a

- :hover不仅可以表示链接的悬停,也可以用于其他标签中

```html

/* 鼠标悬停到.box1盒上,让其本身的背景颜色变为蓝色 */

    .box1:hover{

        background-color: lightblue;

    }

/* 鼠标悬停到.box2盒上,让p标签文字颜色变为红色 */

    .box2:hover p{

        color: red;

    }

/* 鼠标悬停到.box3上,让p标签和h3标签的文字颜色都变为blue */

    .box3:hover h3,

    .box3:hover p{

        color: red;

    }

   

    .box3  :hover{

        color: blue;

    }

```

### 2、相邻选择器

```html

兄弟之间的hover

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

        }

        .box {

            width: 100px;

            height: 100px;

            background: tomato;

        }

        .con {

            width: 300px;

            height: 300px;

            height: 0;

            background: yellowgreen;

            transition: 2s;

        }

        .box:hover+.con {

            height: 300px;

            background-color: blue;

        }

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值