HTML:
<div id="backgroundproduct" style="background-image: url(http://example.com/example.jpg)">
CSS:
#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; }
我使用图像作为背景图像,只有图像的下半部分比顶部更重要.
如何让背景上升一点?
解决方法
如果底部更重要: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%;