前端背景图片全屏
.back-image { background-image: url("./mbvwwo0zubz.jpg"); background-size: cover; background-repeat: no-repeat; background-position: center center; }
在 CSS 文件中,我们使用 background-image 属性设置背景图像的路径,并使用 background-size: cover; 来让图像充满整个容器。background-repeat: no-repeat; 防止图像重复,而 background-position: center center; 将图像居中显示。
在 CSS 中,使用本地文件路径作为背景图像的 URL 是不可行的。浏览器无法直接访问本地文件系统中的图像,因此无法显示图像。
为了在网页中显示背景图像,你应该将图像文件放在 Web 服务器上,并使用服务器上的相对路径或绝对 URL 来引用图像。
假设你将图像文件 mbvwwo0zubz.jpg
放在 Flask 应用的静态文件夹中,你可以使用相对路径来引用它。例如,如果图像文件位于 static/image/mbvwwo0zubz.jpg
,你可以按照以下方式修改 CSS:
cssbody {
font-family: 'Arial', sans-serif;
background-color: #f5f5f5;
margin: 0;
display: flex;
align-items: center;
justify-content: center;
height: 100vh;
background-image: url('../static/image/mbvwwo0zubz.jpg');
background-repeat: no-repeat;
background-size: cover;
}
本文作者:yowayimono
本文链接:
版权声明:本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!