李恒道 发表于 2022-11-23 21:10:57

CSS hover扩大宽度

![图片.png](data/attachment/forum/202211/23/211026a6cqlc16c4u8qaoq.png)
![图片.png](data/attachment/forum/202211/23/211036w770p2z55ckyc53z.png)
![图片.png](data/attachment/forum/202211/23/211043lvb4bvqh69dvq5t9.png)
代码如下
```
<!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>
</head>
<body>
    <div class="wrap">
      <div class="block1"></div>
      <div class="block2"></div>
    </div>
</body>
<style>
    .wrap {
      width: 800px;
      background-color: black;
      height: 240px;
      display: flex;
    }
    .block1 {
      background-color: red;
      flex: 1 1 0;
      transition: all 1s;
    }
    .block2 {
      background-color: yellow;
      flex: 1 1 0;
      transition: all 1s;
    }
    .block1:hover,
    .block2:hover {
      flex-basis: 500px;
      flex-grow: 0;
    }
</style>
</html>

```

公子琛 发表于 2022-11-23 23:47:54

ggnb!{:4_94:}

李恒道 发表于 2022-11-23 23:59:07

公子琛 发表于 2022-11-23 23:47
ggnb!

哥哥牛逼~
头像好看
页: [1]
查看完整版本: CSS hover扩大宽度