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
也可能是问题的一部分)