我创建了一个非常简单的带有全尺寸背景的HTML页面,然而,当我加载页面时,我的背景图片显示为破损。有人知道为什么会发生这种事吗?谢谢!
这是我的代码:
<html>
<head>
<meta charset="utf-8">
<title>TITLE</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
.bgimg {
min-height: 100%;
min-width: 1024px;
width: 100%;
height: auto;
position: fixed;
top: 0;
left: 0;
z-index: -1;
opacity: 0.8;
}
.vdeo {margin: 10% 8%; }
</style>
</head>
<body>
<img class="bgimg" src="https://wallpaperclicker.com/wallpaper/HD-Happy-Birthday-Cartoon-Wallpaper/20306228/">
<iframe class="vdeo" width="600" height="345" align="middle" src="https://www.youtube.com/embed/XXXXXXXX?autoplay=1&controls=0"></iframe>
<script>
for (var i=0;i<4;i++) {
alert(
(i===2)?"Happy Birthday, dear Hub Hub!":"Happy Birthday to YOU!"
)
}
</script>
</iframe>
</body>
</html>我的页面看上去和图片中的一样:我的页面
发布于 2018-03-22 18:17:37
您正在尝试将网页加载为背景图像。
https://wallpaperclicker.com/wallpaper/HD-Happy-Birthday-Cartoon-Wallpaper/20306228/
除非使用服务器应用程序来选择和服务图像,否则src属性值应该以图像文件扩展名结束,例如.jpg或.png。
发布于 2018-03-22 18:20:29
你不能只是把链接到网站与图片,你需要链接到图片。(在您的例子中,它是https://wallpaperclicker.com/storage/wallpaper/HD-Happy-Birthday-Cartoon-Wallpaper-20306228.jpg)尝试它与图片的直接链接。
发布于 2018-03-22 18:21:10
在呈现整个网页的src属性值上使用URI,如果要在该网页内使用图像,则应该使用图像URL。
在这种情况下,我猜是:https://wallpaperclicker.com/storage/wallpaper/HD-Happy-Birthday-Cartoon-Wallpaper-20306228.jpg
如果您没有管理该网站的路线,您可以右键单击,然后检查并查看图像来源。
https://stackoverflow.com/questions/49435784
复制相似问题