本教程操作环境:windows7系统、CSS3&&HTML5版、Dell G3电脑。
html设置背景
1、body标签的bgcolor属性
bgcolor 属性规定文档的背景颜色。
复制代码1
2
3
4
5
6
7
8
9
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
<body bgcolor="#E6E6FA">
<h1>Hello world!</h1>
</body>
</html>
登录后复制
效果图:
注意:如果使用颜色名,不同浏览器的渲染结构不一样,如果使用RGB代码,火狐浏览器无法显示正确颜色。
提示: 如果所有浏览器要显示相同颜色,要使用十六进制的颜色代码。
2、body标签的background属性
background 属性规定规定文档的背景图像。
复制代码1
2
3
4
5
6
7
8
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
<body background="demo/img/1.jpg">
</body>
</html>
登录后复制
效果图:
3、css background 属性
background属性是一个简写属性,可以在一个声明中设置所有的背景属性。
可以设置的属性分别是:
background-color
background-position
background-size
background-repeat
background-origin
background-clip
background-attachment
background-image
示例:
复制代码1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<style>
body
{
background: pink url('smiley.gif') no-repeat fixed center;
}
</style>
</head>
<body>
<p>This is some text</p>
<p>This is some text</p>
<p>This is some text</p>
<p>This is some text</p>
<p>This is some text</p>
<p>This is some text</p>
<p>This is some text</p>
<p>This is some text</p>
<p>This is some text</p>
<p>This is some text</p>
<p>This is some text</p>
<p>This is some text</p>
<p>This is some text</p>
<p>This is some text</p>
<p>This is some text</p>
<p>This is some text</p>
</body>
</html>
登录后复制
效果图:
推荐教程:《html视频教程》
以上就是如何给html设置背景的详细内容,更多请关注靠谱客其它相关文章!
最后
以上就是狂野飞机最近收集整理的关于如何给html设置背景的全部内容,更多相关如何给html设置背景内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复