Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/39.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/89.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
CSS-如何在滚动图像上制作固定背景图像?_Css_Html_Background_Background Image - Fatal编程技术网

CSS-如何在滚动图像上制作固定背景图像?

CSS-如何在滚动图像上制作固定背景图像?,css,html,background,background-image,Css,Html,Background,Background Image,我在顶部有一个带有图像的导航栏。理想情况下,导航栏图像位于背景图像上方,向下滚动时消失。任何可能的方法(2个背景图像1个滚动另一个固定)HTML <div id="scroll" class="nav">Scrolling</div> <div id="fixed" class="nav">Fixed</div> 这将使“固定背景”仅在向下滚动窗口后显示…您的相关内容是什么/HTML? .nav { top: 0; left

我在顶部有一个带有图像的导航栏。理想情况下,导航栏图像位于背景图像上方,向下滚动时消失。任何可能的方法(2个背景图像1个滚动另一个固定)

HTML

<div id="scroll" class="nav">Scrolling</div>
<div id="fixed" class="nav">Fixed</div>
这将使“固定背景”仅在向下滚动窗口后显示…

您的相关内容是什么/HTML?
.nav {
    top: 0; 
      left: 0; 
      height: 100px; // position and size only example, adjust to your needs
      width: 100%;
}
#scroll { 
      position: absolute; 
      background: url(yourimage.png); 
      z-index:1;  
 }
#fixed { 
     position: fixed; 
     background: url(your2ndimage.png); 
     z-index:0; 
  }