CSS背景实例

传统

<style>
           body{
               /*背景图片资源*/
               background-image: url('https://p3.music.126.net/eBF7bHnJYBUfOFrJ_7SUfw==/109951163351825356.jpg?param=300y300');
               /*填充规则*/
               background-repeat: repeat;
               /* background-repeat: no-repeat; */
               /*背景图片位置 两个参数可以用其他单位如px和百分比*/
               background-position: center top;
               /*固定背景不跟随滚动*/
               background-attachment: fixed;   
            }
 </style>

简写

<style>
        body{
            /*可以简写成*/
            /* background: url()||color repeat position attachment; */
            background: url('https://dwz.cn/d8QSroDk') no-repeat center top fixed;
        }
</style>
Last modification:June 21st, 2019 at 01:15 pm
If you think my article is useful to you, please feel free to appreciate

Leave a Comment