html - CSS 背景大小封面和背景位置

标签 html css background-image

HTML:

#backgroundproduct {
  position: fixed;
  top: 5%;
  left: 5%;
  width: 90%;
  height: 90%;
  z-index: 12;
  -webkit-background-size: cover;
  -moz-background-size: cover;
  -o-background-size: cover;
  background-size: cover;
  background-position: top;
}
<div id="backgroundproduct" style="background-image: url(http://example.com/example.jpg)">

我使用图像作为背景图像,只有图像的下部比顶部更重要。

如何让背景稍微上扬一点?

最佳答案

如果底部比较重要:background-position: bottom;

background-position 还允许百分比值:0% 0%; 默认情况下。

The first value is the horizontal position and the second value is the vertical. The top left corner is 0% 0%. The right bottom corner is 100% 100%. If you only specify one value, the other value will be 50%.

你应该试试 background-position: 0% -10%;

关于html - CSS 背景大小封面和背景位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13924626/

相关文章:

html - 为什么我的背景颜色在我的 imgs 之上?

html - PSD 切片背景与图像

html - 如何让我的标签从中间打开,而不是从左边打开?

javascript - 根据哈希值更改单击时按钮的颜色

javascript - Angular - 高度和宽度的属性绑定(bind)不适用于图像

javascript - 我如何使用 javascript 使表格数据占据整个表格行?

javascript - 无法让汉堡菜单在点击时设置动画

javascript - 如何获取分配给 html 表格的 CSS 属性?

css - <a> 标签内的背景图片 <li> 标签在 IE6 和 IE7 中不会消失

css - 使用图像作为通用链接背景