html - 背景图片不符合封面规则

标签 html css styles

我的背景图像随着窗口宽度的减小而缩小。无论显示如何,我都希望图像是完整图像。我将如何实现?下面的代码缩放图像,然后开始只显示一个部分。

header {
position: relative;
width: 100%;
min-height: auto;
text-align: center;
color: #fff;
background-image: url(../img/header.jpg);
background-position: center !important;
background-size: cover;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
}

最佳答案

如果我没看错你的问题,只需将标题宽度设置为图像的宽度即可。

关于html - 背景图片不符合封面规则,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35426080/

相关文章:

javascript - 如何仅在一页中使用 css?

javascript - 我想使用 jQuery 在 html 中使用 data-* 属性将占位符设置为文本框?

html - 保持 <li> 悬停状态的位置一致

html - 在 div 中居中弹出/模态

css - 字体粗细在CSS中没有改变

java - 为 Android 键盘动态应用主题

css - 我们如何确定移动网站的图像大小?

html - 在 html 中缩放图像会在下方创建空白

css - HTML 表格 - 从特定单元格中删除单元格间距/边框

安卓应用风格