4.CSS设计实例
a. 设置背景颜色
<html>
<head>
<style type="text/css">
body {background-color:yellow}
h1 {background-color:#00ff00}
h2 {background-color:transparent}
p {background-color:rgb(250,0,255)}
</style>
</head>
<body>
<h1>This is header 1</h1>
<h2>This is header 2</h2>
<p> This is paragraph</p>
</body>
</html>
b.设置背景图片
<html>
<head>
<style type="text/css">
body {background-image: url('pic.jpg')}
</style>
</head>
<body>
</body>
</html>
c.设置背景图片的位置
<html>
<head>
<style type="text/css">
body { background-image:url('pic.jpg');
background-repeat:no-repeat;
background-position:center
}
</style>
</head>
<body>
</body>
</html>
d.设置背景图片重复
<html>
<head>
<style type="text/css">
body {
background-img:url('pic.jpg');
background-repeat:repeat
}
</style>
</head>
<body>
</body>
</html>