登录

css - 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%就会偏移那么多呢?
不解。

# HTML
伊谢尔伦伊谢尔伦2147 天前622 次浏览

全部回复(6) 我要回复

  • PHP中文网

    PHP中文网2017-04-17 13:56:53

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

    回复
    0
  • 大家讲道理

    大家讲道理2017-04-17 13:56:53

    bgp 的坐标只用负值定位~

    回复
    0
  • 迷茫

    迷茫2017-04-17 13:56:53

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

    回复
    0
  • 阿神

    阿神2017-04-17 13:56:53

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

    回复
    0
  • 黄舟

    黄舟2017-04-17 13:56:53

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

    回复
    0
  • PHP中文网

    PHP中文网2017-04-17 13:56:53

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

    回复
    0
  • 取消回复发送