html - 如何在页面上居中背景图像?
问题描述
我无法将图像作为导航栏下的全屏背景居中。这是我目前正在使用的代码。
header{
background-image: url("design.jpg");
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
background-size: contain;
background-position: center;
background-repeat: no-repeat;
height: 100%
}
解决方案
与您的代码类似的简单方法是
html {
background: url(images/bg.jpg) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
还有一些其他技巧,您将从这里获得
希望能帮助到你。
-NBua
推荐阅读
- c++ - 异常“错误:预期';' 在 ndk-build 的顶级声明符之后
- api - Jmeter 中的 TCP/IP API
- node.js - 未使用用于 alpine linux 的预构建 node-sass
- python - 可视化复函数 z1^n + z2^n = 1
- android - 如何通过从另一个应用程序共享音频来共享音频
- c - Windows VS2017 上的 jemalloc 环境设置
- java - 是否有明确定义的默认端口号用作 Java RMI 注册表端口
- python - Python-Arduino USB 通信浮动错误
- php - 如何使用 pdo 删除多个表中的行
- tweets - 如何使用 tweeter api 返回有关特定位置的所有公共推文