背景颜色(Background Color):

background-color: blue;

  

背景图片(Background Image):

background-image: url('path/to/image.jpg');

  

背景重复(Background Repeat):

background-repeat: repeat;   // 图片在垂直和水平方向重复
background-repeat: repeat-x; // 图片只在水平方向重复
background-repeat: repeat-y; // 图片只在垂直方向重复

  

背景位置(Background Position):

background-position: left top;
background-position: center center;
background-position: 100px 200px; // 使用具体的数值

  

背景附着(Background Attachment):

background-attachment: scroll; // 背景图像随元素内容滚动
background-attachment: fixed;  // 背景图像固定不动

  

demo:

<style>
.background {
    background-image: url('../assets/login.jpg');
    /* 替换为您的图片路径 */
    background-size: cover;
    /* 覆盖整个元素 */
    background-position: center;
    /* 图片居中 */
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    /* 使用Flexbox */
    justify-content: center;
    /* 水平居中 */
    align-items: center;
    /* 垂直居中 */
}</style>

  

posted on 2024-01-25 13:09  黑逍逍  阅读(4)  评论(0编辑  收藏  举报