Home  >  Q&A  >  body text

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

伊谢尔伦伊谢尔伦2721 days ago860

reply all(6)I'll reply

  • PHP中文网

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

    I didn’t see the effect of your code. I’m not sure what to say. Please give me a link first

    reply
    0
  • 大家讲道理

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

    The coordinates of bgp are only positioned with negative values~

    reply
    0
  • 迷茫

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

    10% will offset that much. It depends on the size of your box (picture). This is relative.

    reply
    0
  • 阿神

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

    The key depends on how you position it. It is recommended to take out the source code and take a look

    reply
    0
  • 黄舟

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

    This attribute sets the position of the background-image, and it also depends on how you position the box and the size of the image

    reply
    0
  • PHP中文网

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

    Look at the calculation method of percentage, which is to align the position corresponding to 10% of the picture with the position corresponding to 10% of the background positioning.

    reply
    0
  • Cancelreply