背景颜色(Background Color):

1
background-color: blue;

  

背景图片(Background Image):

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

  

背景重复(Background Repeat):

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

  

背景位置(Background Position):

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

  

背景附着(Background Attachment):

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

  

demo:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<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   黑逍逍  阅读(6)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
历史上的今天:
2023-01-25 UDP
2023-01-25 nginx 做图像服务器(web服务器),生成图片的URL,存在数据库,图片地址让前端访问
2023-01-25 slam 导航



点击右上角即可分享
微信分享提示