解决IE不支持 background-size:cover;

本文介绍了一种在CSS中设置背景图片的方法,并特别说明了如何让背景图片在不同浏览器下正常显示,包括针对IE6的特殊处理方式。还强调了图片路径的正确使用方法。

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

   .page{
      background:url(images/page2_bg.jpg) top center no-repeat; background-size:cover;
      filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='images/page2_bg.jpg',  sizingMethod='scale');
      _filter:none;
   }


最后一句是针对IE6,没法平铺,只能背景图片居中显示

图片路径必须是绝对路径,也就是说,不能放在css文件里面,而要把此css放在html里面

转载于:https://www.cnblogs.com/dengxiaoqing/p/5138712.html

<!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>彼岸花开</title> <style> body { margin: 0; padding: 0; font-family: 'Poppins', sans-serif; height: 1000px; } .banner { width: 100%; height: 100vh; overflow: hidden; display: flex; justify-content: center; align-items: center; } .banner video { position: absolute; top: 0; left: 0; object-fit: cover; width: 100%; height: 100%; pointer-events: none; } .banner .content { position: relative; z-index: 1; max-width: 1000px; margin: 0 auto; text-align: center; } .banner .content h1 { margin: 0; padding: 0; font-size: 3.5em; text-transform: uppercase; color: #d11090; } .banner .content p { font-size: 1.5em; color: #fff; } h1::after { content: ''; position: absolute; top: 0; left: 0; color: transparent; background-image: linear-gradient(to right, #c23616, #192a56, #00d2d3, yellow, #6d214f, #2e86de, #4cd137, #e84118); background-clip: text; -webkit-background-clip: text; clip-path: circle(100px at 0% 50%); animation: move 5s infinite; } @keyframes move { 0% { clip-path: circle(100px at 0% 50%); transform: translateX(0); } 50% { clip-path: circle(100px at 100% 50%); transform: translateX(10px); } 100% { clip-path: circle(100px at 0% 50%); transform: translateX(0); } } </style> </head> <body> <div class="banner"> <video autoplay loop muted> <source src="flower.mp4" type="video/mp4" controls> <!-- <audio src="./Christmas.mp3" autoplay="autoplay" loop></audio>--> </video> <div class="content"> <h1></h1> </div> </div> </body> </html>
最新发布
06-11
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值