我在引导程序框架中使用了一些(貌似)基本的CSS,并且由于某种原因,一旦我将代码放入引导程序中,它就会开始闪烁,并且不显示图像或进行转换。

如果在Chrome / FF /(甚至IE)上运行here,则可以看到图像在鼠标悬停时加载并转换。如果您将它加载到Safari上,尽管它只是坐在那里,并且仅显示卡的背面。

我已经把这个问题扯了几个小时,任何建议将不胜感激!

谢谢 :)

我的代码是:

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Bootstrap 101 Template</title>
    <link href="css/bootstrap.min.css" rel="stylesheet">
    <link rel="stylesheet" type="text/css" href="/dickshit.css">
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
  </head>
  <body>

<div class="row">
    <div class="col-md-6 col-md-offset-3">

<div id="f2_container">
<div id="f2_card" class="shadow">
  <div class="front face">
    <img src="/cardbacks/default.png" height="359" width="241"/>
  </div>
  <div class="back face center">
    <p>This is nice for exposing more information about an image.</p>
    <p>Any content can go here.</p>
        </div>
</div>
</div>
    </div></div>


    <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
    <!-- Include all compiled plugins (below), or include individual files as needed -->
    <script src="js/bootstrap.min.js"></script>
  </body>
</html>


我的CSS是:

.face {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
}
.face.back {
  display: block;
  transform: rotateY(180deg);
  box-sizing: border-box;
  border-radius: 10px;
  padding: 10px;
  color: white;
  text-align: center;
  background-color: #aaa;
}


#f1_container {
  position: relative;
  float: left;
  margin: 10px 20px 10px  auto;
  width: 241px;
  height: 359px;
  z-index: 1;
}
#f1_container {
  perspective: 1000;
}
#f1_card {
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: all 1.0s linear;
}
#f1_container:hover #f1_card {
  transform: rotateY(180deg);
}

#f2_container {
  position: relative;
  float: left;
  margin: 10px 20px 10px auto;
  width: 241px;
  height: 359px;
  z-index: 1;
}
#f2_container {
  perspective: 1000;
}
#f2_card {
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: all 1.0s linear;
}
#f2_container:hover #f2_card {
  transform: rotateY(180deg);
}

最佳答案

您正在使用Safari“不支持”的某些CSS。解决此问题所需要做的是在其中一些前面添加-webkit-(如下面链接的W3schools页面中所指定):


转换(http://www.w3schools.com/css/css3_2dtransforms.asp
转换样式(http://www.w3schools.com/cssref/css3_pr_transform-style.asp
过渡(http://www.w3schools.com/css/css3_transitions.asp
透视图(http://www.w3schools.com/cssref/css3_pr_perspective.asp
背面可见性(http://www.w3schools.com/cssref/css3_pr_backface-visibility.asp


一旦为这些样式添加了额外的代码,结果也将在Safari中看起来也不错(我在Safari 5.1.7中进行了测试),CSS如下所示:

.face {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}
.face.back {
    display: block;
    transform: rotateY(180deg);
    -webkit-transform: rotateY(180deg);
    box-sizing: border-box;
    border-radius: 10px;
    padding: 10px;
    color: white;
    text-align: center;
    background-color: #aaa;
}
#f1_container {
    position: relative;
    float: left;
    margin: 10px 20px 10px auto;
    width: 241px;
    height: 359px;
    z-index: 1;
}
#f1_container {
    perspective: 1000px;
    -webkit-perspective:1000px;
}
#f1_card {
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
    -webkit-transform-style: preserve-3d;
    transition: all 1.0s linear;
    -webkit-transition: all 1.0s linear;
}
#f1_container:hover #f1_card {
    -webkit-transform: rotateY(180deg);
    transform: rotateY(180deg);
}
#f2_container {
    position: relative;
    float: left;
    margin: 10px 20px 10px auto;
    width: 241px;
    height: 359px;
    z-index: 1;
}
#f2_container {
    perspective: 1000px;
    -webkit-perspective: 1000px;
}
#f2_card {
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
    -webkit-transform-style: preserve-3d;
    transition: all 1.0s linear;
    -webkit-transition: all 1.0s linear;
}
#f2_container:hover #f2_card {
    transform: rotateY(180deg);
    -webkit-transform: rotateY(180deg);
}

关于css - 无法在Safari中加载图片/CSS转换,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/25477820/

10-11 12:53