为什么在某些网站上无法查看背景图像
why is it not possible to view background-image in some sites
如果您访问这样的网站 here 并尝试使用浏览器查看背景图片,那是不可能的。
这是怎么做到的?我想在我的网站上实现它。提供一个 css 或 js 脚本来实现这一点。谢谢
编辑:
请不要这样说:
#selector{
background : url('http://someurl.com') no-repeat;
}
因为我试过了,但没有成功。
在这种情况下,背景图片不是 CSS 背景,它只是一张设置为展开整个页面并使用 z-index 发送到背景的图片。
图片的HTML:
<div id="bg-top" class="bg-top">
<div>
<img src="http://netstorage.metrolyrics.com/artists/hero/default/9.jpg" alt="Westlife lyrics">
</div>
</div>
CSS将图片展开后送至后台:
.bg-top {
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 584px;
background: #000;
border-bottom: 1px solid #000;
overflow: hidden;
z-index: -2; // This is the key, it makes it to be at the background
}
如果您访问这样的网站 here 并尝试使用浏览器查看背景图片,那是不可能的。
这是怎么做到的?我想在我的网站上实现它。提供一个 css 或 js 脚本来实现这一点。谢谢
编辑:
请不要这样说:
#selector{
background : url('http://someurl.com') no-repeat;
}
因为我试过了,但没有成功。
在这种情况下,背景图片不是 CSS 背景,它只是一张设置为展开整个页面并使用 z-index 发送到背景的图片。
图片的HTML:
<div id="bg-top" class="bg-top">
<div>
<img src="http://netstorage.metrolyrics.com/artists/hero/default/9.jpg" alt="Westlife lyrics">
</div>
</div>
CSS将图片展开后送至后台:
.bg-top {
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 584px;
background: #000;
border-bottom: 1px solid #000;
overflow: hidden;
z-index: -2; // This is the key, it makes it to be at the background
}