【问题标题】:Keep background-size: cover, but also enable size auto for iphones?保持背景尺寸:覆盖,但也为iphone启用尺寸自动?
【发布时间】:2017-07-20 16:52:11
【问题描述】:

在 CSS 样式文件中我有这一行

background-size: cover;

但是背景图像在 iPhone 上将不可见。所有其他手机都可以看到它。

然后如果我这样设置尺寸

background-size: auto;

所有移动设备 + iPhone 都可以看到背景,但网页很奇怪。图像大小不合适,但您可以看到图像与其容器之间存在一些间距。

解决这种情况的正确方法是什么?

【问题讨论】:

  • 你能分享更多你的代码吗?

标签: css background-size


【解决方案1】:

试试这个:

.backgroundImage { position: fixed; top: 0; left: 0; min-width: 100%; min-height: 100%; }

https://codepen.io/anon/pen/YQmEQw

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-03-24
    • 1970-01-01
    • 2013-10-31
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多