首頁  >  問答  >  主體

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 天前868

全部回覆(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
  • 取消回覆