更新时间:2020-03-08 文章分类:网页技术课堂
| 
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <style>
        div{
            height: 400px;
            border: 1px solid red;/*1px的红色实线*/
            background-color: blue;
            background-image: url("../../img/lianxiang.jpg");
 
            background-repeat: no-repeat;/*1、no-repeat 图片保留自身大小,不平铺
                                          2、repeat-x 水平方向上图片平铺
                                          3、repeat-y 垂直方向上图片平铺*/
       
            background-position: center top;
            /*background-size: 100% 100%;*/ /*背景图片的大小*/
            /*background-size: contain;*//*contain:图片宽高等比例缩放,直到宽或高填满父布局,有可能出现图片填充布局不完整*/
            background-size: cover; /*cover:图片宽高等比例缩放,直到较小的宽或高填满父布局,可能出现图片溢出*/
 
 
        }
    </style>
    <title>背景图片</title>
</head>
<body>
<div>
</div>
</body>
</html> | 
