Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/90.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
Html 空网页上的完整窗口背景?_Html_Css_Background - Fatal编程技术网

Html 空网页上的完整窗口背景?

Html 空网页上的完整窗口背景?,html,css,background,Html,Css,Background,有没有办法在不使用视口单位的情况下在空网页上应用完整的窗口背景 实际的页面不是空的,但它的所有元素都被绝对定位,当我试图针对不支持vh/vw的浏览器进行验证时,背景停止工作,我猜原因是流中没有任何内容,因此主体没有高度。我可以用绝对单位(像素或em)固定高度,但这并不完全适合窗口大小 更新 有些人似乎认为“空网页”不够具体(搁置问题),所以这里是一个空的网页(OK,与CSS的链接)看起来像: <html> <head> <link rel="styles

有没有办法在不使用视口单位的情况下在空网页上应用完整的窗口背景

实际的页面不是空的,但它的所有元素都被绝对定位,当我试图针对不支持
vh
/
vw
的浏览器进行验证时,背景停止工作,我猜原因是流中没有任何内容,因此
主体没有高度。我可以用绝对单位(像素或em)固定高度,但这并不完全适合窗口大小

更新 有些人似乎认为“空网页”不够具体(搁置问题),所以这里是一个空的网页(OK,与CSS的链接)看起来像:

<html>
  <head>
    <link rel="stylesheet" href="mystyle.css" type="text/css" />
  </head>
  <body>
  </body>
</html>

将“html”和“body”标记的高度设置为100%应该可以。将“html”和“body”标记的高度设置为100%应该可以。您可能有一些选择。您可以将
位置:fixed
div
放置在具有背景定义的标记顶部:

<body>
    <div class="window-background"></div>
    ...


.window-background {
    background-image: url('your image');
    background-size: cover;
    bottom: 0;
    left: 0;
    position: fixed;
    right: 0;
    top: 0;
}

你可能有一些选择。您可以将
位置:fixed
div
放置在具有背景定义的标记顶部:

<body>
    <div class="window-background"></div>
    ...


.window-background {
    background-image: url('your image');
    background-size: cover;
    bottom: 0;
    left: 0;
    position: fixed;
    right: 0;
    top: 0;
}

实际上,在
html
上-这就是我所缺少的。如果应用于
html
标记,则不必声明
高度:100%
@KevinBoucher:如果使用
背景尺寸:封面
,则不必声明,但如果使用
背景尺寸:100%100%
。在
html
上,实际上-这就是我所缺少的。如果应用于
HTML
标记,则不必声明
高度:100%
@KevinBoucher:如果使用
背景尺寸:封面
,则不必声明,但是如果您使用
background size:100%100%
,将
html
标记上的背景设置为
background size
设置为
cover
确实有效。(我没有测试你的第一个技巧,因为它可以使用更简单的解决方案。)在
html
标记上设置
background size
设置为
cover
确实有效。(我没有测试您的第一个技巧,因为它适用于更简单的解决方案。)
html {
    background-image: url('your image');
    background-size: cover;
}