我正在为 My new website 设置着陆页
我创建了一张图片,并将其设置为背景图片。不幸的是,我似乎完全不知道如何让它全屏显示和滚动 - 所以你可以向上/向下滚动以查看完整图像 - 但没有任何空白或任何东西。
<!DOCTYPE html>
<html>
<title>On The Ropes Boxing! Coming Soon!</title>
<body>
<style>
html {
height: 100%;
margin:0px;
background: url(comingsoon.jpg) no-repeat top center;
background-size: cover;
background-attachment: scroll;
}
body {
min-height: 100%;
margin:0px;
}
#appcontainer {
position: relative
background-color: rgba(255, 255, 255, 0.7);
width:560px; height:2220px;
left:20px; top:20px;
}
<img src="comingsoon.jpg" style="minwidth:100%;height:100%;" alt="" />
</style>
</body>
</html>
这就是我目前所拥有的。我对 HTML 和 CSS 完全陌生,所以我基本上只是在工作中学习并通过反复试验。我完全希望有人告诉我我做这件事的方式完全错误。感谢任何建议 - 请注意,我可能需要被告知好像我是个白痴 :)
非常感谢。
最佳答案
替换 img
用这个标记你的代码:
<img src="http://www.ontheropesboxing.com/comingsoon.jpg" style="width:100%;position:absolute;z-index:-1" alt="" />
并将其移出 style
标签。
关于html - 将背景图像设置为全屏且可滚动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22264874/