关于background复合写法

常用的复合样式写法

1. ~image ~repeat ~attachment ~position/~size

2. ~image ~repeat ~attachment ~position

3. ~image ~repeat ~position/~size

例子:直接上代码

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>roadloser</title>
  <style>
    body{
    background: url(images/luchi.jpg) no-repeat scroll top/cover;
  }
  </style>
</head>
<body>

</body>
</html>

结语

刚学前端时,背景复合写法百度了半天都没找到实例,最后自己实践了才知道background-size是在background-position前加“/”,而不是用空格隔开。

猜你喜欢

转载自blog.csdn.net/roadloser/article/details/88977912