html网页制作背景
时间: 2023-12-26 19:27:37 浏览: 28
以下是两种制作HTML网页背景的方法:
1. 使用背景图片并设置背景比例为窗口的100%:
```html
<body style="background-image: url('photo/动态.gif'); background-repeat: no-repeat; background-attachment: fixed; background-size: 100% 100%;">
</body>
```
2. 使用背景图片并固定位置:
```html
<body style="background-image: url('photo/动态.gif'); background-repeat: no-repeat; background-attachment: fixed;">
</body>
```
相关问题
html网页制作背景图片
在HTML网页中设置背景图片有多种方法。您可以在body标签中使用background属性来设置背景图片的路径,同时使用style属性来设置背景图片的显示方式,例如不重复显示、固定位置和100%比例。另外,您还可以使用CSS样式表来设置背景图片,通过给body元素添加背景图片的URL和其他属性来实现。
以下是一个设置背景图片的HTML代码示例:
```
<html>
<head>
<meta charset="UTF-8">
<title>HTML设置页面背景</title>
<style>
body {
background-image: url("01.jpg");
background-repeat: no-repeat;
background-attachment: fixed;
background-size: 100% 100%;
}
</style>
</head>
<body>
</body>
</html>
```
html网页制作背景图片局中
要让背景图片在网页中居中显示,可以使用CSS的background属性和background-position属性来设置。具体步骤如下:
1. 在CSS中设置背景图片:
```css
body {
background-image: url("yourimage.jpg");
background-repeat: no-repeat;
background-size: cover;
background-position: center;
}
```
2. 在HTML中引入CSS文件:
```html
<head>
<link rel="stylesheet" href="style.css">
</head>
```
这样就可以让背景图片在网页中居中显示了。其中,background-size设置为cover可以让背景图像始终铺满整个网页,而background-position设置为center可以让背景图片在水平和垂直方向上都居中显示。