html - 如何在html中创建一个视差网站(为什么我的背景图像不会覆盖整个屏幕?)

标签 html css parallax

我正在创建视差背景,但背景图像没有覆盖整个屏幕 谁能告诉我如何解决它?这就是我所拥有的视差..

    <style>
    .parallax { 
        /* The image used */
        background-image: url("rocket-2680282_1920 (1).jpg");
        /* Set a specific height */
        height: 1078px; 
        /* Create the parallax scrolling effect */
        background-attachment: fixed;
        background-position: initial;
        background-repeat: no-repeat;
        background-size: cover;
    }
   </style>

如果你想明白我的意思,这里是网站link

最佳答案

看起来你的 body 有一个 margin 尝试将它添加到你的 css 中:

body{
 margin:0px;
}

关于html - 如何在html中创建一个视差网站(为什么我的背景图像不会覆盖整个屏幕?),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47243253/

相关文章:

html - 如何使顶部带有 div 的背景表现得像视差背景

html - 固定位置透视

javascript - 我可以使用 jQuery 选择#id > #id 吗?

html - 如何使用 Bootstrap 减少两列之间的过多空间

html - 如何使用 CSS3 在元素的背景中放置和旋转文本?

html - Safari 中不显示视差页脚

javascript - 当按钮为空时,按钮尺寸会变得太小

javascript - BootGrid 示例 JSON 不起作用(带代码)

html - 获取 2 个 div,使用精确的像素将页面完美地分成 1/2

css - 如何在 Bootstrap 4 中创建卡片库?