CSS全屏背景图是实现网页视觉效果的重要手段之一,下面我们来详细介绍它的设置方法。在CSS中设置全屏背景图的基本语法如下:body { background: url(图片地址) norepeat c...
CSS全屏背景图是实现网页视觉效果的重要手段之一,下面我们来详细介绍它的设置方法。
在CSS中设置全屏背景图的基本语法如下:
body {
background: url(图片地址) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
} <!DOCTYPE html>
<html>
<head>
<title>全屏背景图实例</title>
<style>
body {
background: url(bg.jpg) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
</style>
</head>
<body>
<h1>这是一个具有全屏背景图的网页</h1>
</body>
</html>