CSS3背景图片百分比及应用

1.background-size:100% auto,意思是背景图片宽度为元素宽度*100%,高度等比缩放。

2.等价写法

  • top left, left top 等价于 0% 0%.
  • top, top center, center top 等价于 50% 0%.
  • right top, top right 等价于 100% 0%.
  • left, left center, center left 等价于 0% 50%.
  • center, center center 等价于 50% 50%.
  • right, right center, center right 等价于 100% 50%.
  • bottom left, left bottom 等价于 0% 100%.
  • bottom, bottom center, center bottom 等价于 50% 100%.
  • bottom right, right bottom 等价于 100% 100%.

3.百分比计算公式

标准规定:background-position:perenct的参考值为: (容器宽度 - 背景图片宽度).

原文地址:https://www.cnblogs.com/liaoliao985786516/p/5646284.html