前端页面 CSS+HTML5 简单实现视觉差效果 很简单

话不多说   先看效果 后看代码  (gif 有点模糊   见谅)

 

 

代码如下:

<!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
        }
        /* 设置窗口自适应的 */
        
        html,
        body {
            height: 100%
        }
        
        div {
            height: 100%;
            /* 取消平铺 */
            background-repeat: no-repeat;
            /* 背景固定 */
            background-attachment: fixed;
            /* 背景尺寸大小 */
            background-size: cover
        }
        
        .red {
            /* 插入背景图片 */
            background-image: url('https://img0.baidu.com/it/u=4285949849,2816553460&fm=253&fmt=auto&app=138&f=JPEG?w=800&h=500');
        }
        
        .blue {
            /* 插入背景图片 */
            background-image: url('https://img1.baidu.com/it/u=1748679971,3116280725&fm=253&fmt=auto&app=138&f=JPEG?w=800&h=500');
        }
        
        .yellow {
            /* 插入背景图片 */
            background-image: url('https://img2.baidu.com/it/u=4154226613,2211547833&fm=253&fmt=auto&app=138&f=JPEG?w=889&h=500');
        }
    </style>
</head>

<body>
    <!-- 三个盒子切换的视觉差案例 -->
    <div class="red"></div>
    <div class="blue"></div>
    <div class="yellow"></div>
</body>

</html>

注:代码中所用到的图片均来自https://image.baidu.com/search/index?tn=baiduimage&ipn=r&ct=201326592&cl=2&lm=-1&st=-1&fm=result&fr=&sf=1&fmq=1660898031162_R&pv=&ic=&nc=1&z=&hd=&latest=&copyright=&se=1&showtab=0&fb=0&width=&height=&face=0&istype=2&dyTabStr=MCwzLDIsMSw2LDQsNSw3LDgsOQ%3D%3D&ie=utf-8&sid=&word=%E7%94%B5%E8%84%91%E5%85%A8%E5%B1%8F%E6%A1%8C%E9%9D%A2

如有侵权,请联系删除

  • 4
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

Lizy!

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

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

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

打赏作者

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

抵扣说明:

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

余额充值