<!DOCTYPE html>
<html>
<head>
<style>
body {
background-image: url("/i/photo/tree.png");
background-repeat: no-repeat;
background-position: right top;
margin-right: 200px;
}
</style>
</head>
<body>
<p>科学熊,将背景图片设置到body元素的右上角</p>
</body>
</html>
效果:
background-repeat: no-repeat;设置背景是否重复显示:no-repeat为不重复,repeat为重复。
设置为repeat的代码:
<!DOCTYPE html>
<html>
<head>
<style>
body {
background-image: url("/i/photo/tree.png");
background-repeat: repeat;
background-position: right top;
margin-right: 200px;
}
</style>
</head>
<body>
<p>科学熊,将背景图片设置到body元素的右上角</p>
</body>
</html>
效果:密集恐惧症