ios - 为什么 iOs Safari 会显示完整尺寸的背景图像?

标签 ios css background-image background-size

我在一个网站上工作,那里有一些带有背景图像作为缩略图的框。我必须使用背景图像,因为我们正在使用的 CMS 已经过时,而且客户端不会更改(mon€y 是主要问题)。

我发现 iPad2 和 iPhone5(最新的 iOS)上的 iOs Safari 有一个奇怪的行为,但不知道为什么。

这是我的代码:

a img,
.thumb,
figcaption,
a:hover .thumb {
  -webkit-transition: all .3s;
  -moz-transition: all .3s;
  -ms-transition: all .3s;
  -o-transition: all .3s;
  transition: all .3s;
}
.thumb {
  height: 250px;
  margin-bottom: 28px;
  overflow: hidden;
  background-size: 100% 100%;
  background-position: center;
  background-repeat: no-repeat;
}
figcaption {
  background-color: #b61910;
  background-color: rgba(182, 25, 16, .85);
  position: absolute;
  height: 39px;
  bottom: 35px;
  color: white;
  width: calc(100% - 30px);
}
figcaption h3 {
  font-style: normal;
  position: absolute;
  bottom: 5px;
  margin-top: 0;
  margin-bottom: 0;
  padding: 10px 0 0 5px;
  transition: transform 0.3s;
  transform: translate3d(0, 0%, 0);
}
a:hover h3 {
  transform: translate3d(0, -20%, 0);
  text-shadow: 1px 1px 1px #000;
}
a:hover figcaption {
  height: 5px;
}
a:hover .thumb {
  background-size: 120% 120%;
  opacity: .8
}
<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css" rel="stylesheet" />
<div class="container">
  <div class="row">
    <a href="">
      <div class="col-sm-12">
        <figure class="thumb" style="background-image:url(http://lorempixel.com/output/food-h-c-850-890-7.jpg)">
          <figcaption>
            <h3>Product-Title</h3>
          </figcaption>
        </figure>
      </div>
    </a>
  </div>
</div>

在我的桌面上,它显示了整个图像,但在 iOS 上,它看起来像是在缩略图框内显示了原始大小。 我该如何解决这个问题?

任何帮助都会很棒 :) 谢谢

情境

最佳答案

也许吧? https://css-tricks.com/forums/topic/full-page-backgrounds-on-ios-background-size-cover/

代码:

  background: url(images/bg.jpg) no-repeat center center fixed; 
  -webkit-background-size: cover;
  -moz-background-size: cover;
  -o-background-size: cover;
  background-size: cover;

关于ios - 为什么 iOs Safari 会显示完整尺寸的背景图像?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29946848/

相关文章:

html - 将引用 SVG 图像嵌入 HTML 文件

ios - Swift - 为 UITableViewCell 中的 UICollectionViewCell 设置高度

iphone - 我应该以编程方式在 init 或 ViewDidLoad 中添加 subview ,为什么?

objective-c - iOS - heightForRowAtIndexPath 在滚动期间不触发

ios - 如何在 Swift 上获取基于 GMT 的时差

html - 使用我的 CSS 选择器覆盖所有给定的 CSS 样式

javascript - 将一个div带到:active state via jquery . trigger()方法

iPhone - UITableView 背景

javascript - 如何防止网站后台加载滞后?

css - iphone 不显示背景图片