Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/34.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 - Fatal编程技术网

Html 在我的网站中保持相同的背景

Html 在我的网站中保持相同的背景,html,css,Html,Css,我想保持一个静态的背景为我的网站一样,通过所有的网页。 也就是说,整个应用程序的背景应该是相同的。 我试过了 html { height: 300px; width: 300px; background: #f00 url(http://d1c739w2xm33i4.cloudfront.net/2.2/top_image.jpg); background-size: 100%; background-repeat: no-repeat; } 但这只会将

我想保持一个静态的背景为我的网站一样,通过所有的网页。 也就是说,整个应用程序的背景应该是相同的。 我试过了

html {
    height: 300px;
    width: 300px;
    background: #f00 url(http://d1c739w2xm33i4.cloudfront.net/2.2/top_image.jpg);
    background-size: 100%;
    background-repeat: no-repeat;
}
但这只会将背景指定给我网站中的选定区域


如何实现这一点?

html
更改为
body

body
{
    height: 300px;
    width: 300px;
    background: #f00 url(http://d1c739w2xm33i4.cloudfront.net/2.2/top_image.jpg);
    background-size: 100%;
    background-repeat: no-repeat; 
}

html
更改为
body

body
{
    height: 300px;
    width: 300px;
    background: #f00 url(http://d1c739w2xm33i4.cloudfront.net/2.2/top_image.jpg);
    background-size: 100%;
    background-repeat: no-repeat; 
}

它应该是
body
而不是
html

body {
  height: 300px;
  width: 300px;
  background: #f00 url(http://d1c739w2xm33i4.cloudfront.net/2.2/top_image.jpg);
  background-size: 100%;
  background-repeat: no-repeat;
}

考虑一下高度和宽度。

应该是
body
而不是
html

body {
  height: 300px;
  width: 300px;
  background: #f00 url(http://d1c739w2xm33i4.cloudfront.net/2.2/top_image.jpg);
  background-size: 100%;
  background-repeat: no-repeat;
}
考虑一下高度和宽度。

尝试使用

body{
     background: #f00 url(http://d1c739w2xm33i4.cloudfront.net/2.2/top_image.jpg);
     background-size: 100%;
     background-repeat: no-repeat;
}
并确保所有html页面都链接到css文件

<link rel="stylesheet" type="text/css" href="path_to_your_file.css" media="all"/>

尝试使用

body{
     background: #f00 url(http://d1c739w2xm33i4.cloudfront.net/2.2/top_image.jpg);
     background-size: 100%;
     background-repeat: no-repeat;
}
并确保所有html页面都链接到css文件

<link rel="stylesheet" type="text/css" href="path_to_your_file.css" media="all"/>

试试这个

body{
  height: 100%;
  width: 100%;
  background: #f00 url(http://d1c739w2xm33i4.cloudfront.net/2.2/top_image.jpg);
  background-size: 100%;
  background-repeat: no-repeat;
}
试试这个

body{
  height: 100%;
  width: 100%;
  background: #f00 url(http://d1c739w2xm33i4.cloudfront.net/2.2/top_image.jpg);
  background-size: 100%;
  background-repeat: no-repeat;
}

问题是因为您在
css
类中分配了
高度
宽度

问题是因为您在
css
类中分配了
高度
宽度

使用
背景尺寸:封面
背景大小:100%100%
。不要为
.html
选择器使用
高度
宽度
属性。在
.body
选择器上应用属性。
请参考更多知识。

使用
背景尺寸:封面
背景大小:100%100%
。不要为
.html
选择器使用
高度
宽度
属性。在
.body
选择器上应用属性。
请参考更多知识。

将其应用于
正文{…}
?(注意-将高度和宽度设置为
300px
也可能是问题的一部分)将其应用于
主体{…}
?(注意-将高度和宽度设置为
300px
也可能是问题的一部分)