background-position使用疑惑。

DEMO

我看文档上是这样写的:

A percentage for the horizontal offset is relative to (width of background positioning area - width of background image). A percentage for the vertical offset is relative to (height of background positioning area - height of background image), where the size of the image is the size given by ‘background-size’.

那么为什么10%就会偏移那么多呢?
不解。

阅读 3.6k
6 个回答

没看到你的代码效果,不好怎么说,先给个链接

bgp 的坐标只用负值定位~

10%就会偏移那么多,要看你盒子(图片)本身大小吧,这个是相对的。

关键看你如何定位,建议把源码拿出来看看

新手上路,请多包涵

这个属性设置background-image的位置,也看你怎么定位盒子和图片的大小

bg-pos.png

看百分比的计算方式, 是把图片的10%对应的位置,与背景定位的10%对应位置对齐。

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题