【问题标题】:CSS not working on safari , works fine on ChromeCSS 在 safari 上不工作,在 Chrome 上工作正常
【发布时间】:2020-12-29 17:14:17
【问题描述】:

在 CSS 中,使用 position:fixed 时,当我尝试在 safari 和 Chrome 上打开同一页面时,我得到了不同的结果。我附上了屏幕截图和css代码sn-p。

.block--active {
  position: fixed;
  padding-top: 1%;
  bottom:2%;
  left: 0;
  z-index: 1;
  height: 100%;
  width: 100%; 
} 

似乎使用“位置:固定”会导致一些问题,并且它会使元素在不同的视口上生成,在我的情况下是整个屏幕。应该发生的事情(比如在 chrome 中)是应该在 parent 的视口中的元素。所以设置为 100% 的宽度和高度应该只在父视口中打开模型,而不是在整个碎石中。

截图:

Chrome ScreenShot :

Safari Screenshot

.block-wrap {
  width: 900px;
  height: 400px;
  position: relative;
  overflow: hidden;
  border-radius: 8px;
  margin: auto;
}

.block-col {
  display: box;
  -webkit-display: box;
  height: 100%;
  margin: 0 12px;
  width: 128px;
}

.block {
  height: 128px;
  width: 100%;
  border-radius: 8px;
  margin: auto 0;
  position: relative;
  will-change: transform;
}
.block:not(.block--active) {
  cursor: pointer;
}
.block:not(.block--active):hover, .block:not(.block--active).fake-hover {
  -webkit-transform: translateY(-12px);
          transform: translateY(-12px);
}
.block:not(.block--active):hover:after, .block:not(.block--active).fake-hover:after {
  content: "";
  display: block;
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  -webkit-transform: scale(1.1) translateY(12px);
          transform: scale(1.1) translateY(12px);
}

.block:not(.block--active):active {
  -webkit-transform: scale(0.9) translateY(-12px);
          transform: scale(0.9) translateY(-12px);
}
.block--active {
  position: fixed;
  padding-top: 1%;
  bottom:2%;
  left: 0;
  z-index: 1;
  height: 100%;
  width: 100%; 
}
.block--active .clogo{
  width: 150px !important;
  height:150px !important;
}

.block--active .ctext{
  color: rgb(126, 122, 122) !important;
  font-size: 36px;
  position: relative;
  bottom: 25px;
}
.block--transition {
  -webkit-transition: -webkit-transform 0.185s cubic-bezier(0.4, 0, 0, 1);
  transition: -webkit-transform 0.185s cubic-bezier(0.4, 0, 0, 1);
  transition: transform 0.185s cubic-bezier(0.4, 0, 0, 1);
  transition: transform 0.185s cubic-bezier(0.4, 0, 0, 1), -webkit-transform 0.185s cubic-bezier(0.4, 0, 0, 1);
}

.block-content {
  display: none;
  padding: 24px;
}
.block--active .block-content {
  display: block;
}

.block-content__header {
  background: rgba(0, 0, 0, 0.1);
  padding: 24px;
  margin: -24px -24px 24px;
  overflow: hidden;
  color: rgba(14, 13, 13, 0.85);

}

.block-content__header__text {
  will-change: transform;
  margin: 0;
  opacity: 0;
  font-size: 2em;
  color: rgb(126, 122, 122);
}
.block--active .block-content__header__text {
  -webkit-animation: content-in 0.225s cubic-bezier(0, 0, 0.2, 1) forwards;
          animation: content-in 0.225s cubic-bezier(0, 0, 0.2, 1) forwards;
  -webkit-animation-delay: .15s;
          animation-delay: .15s;
}

.block-content__body {
  will-change: transform;
  opacity: 0;
  font-size: 18px;
  line-height: 1.333;
  -webkit-animation: content-in 0.245s cubic-bezier(0, 0, 0.2, 1) forwards;
          animation: content-in 0.245s cubic-bezier(0, 0, 0.2, 1) forwards;
  -webkit-animation-delay: .1s;
          animation-delay: .1s;
  margin: 0 0 20px;
  color: rgba(14, 13, 13, 0.85);
 
}

.block-content__button {

}

@-webkit-keyframes content-in {
  0% {
    opacity: 0;
    -webkit-transform: translateY(128px);
            transform: translateY(128px);
  }
  100% {
    opacity: 1;
    -webkit-transform: translateY(0);
            transform: translateY(0);
  }
}

@keyframes content-in {
  0% {
    opacity: 0;
    -webkit-transform: translateY(128px);
            transform: translateY(128px);
  }
  100% {
    opacity: 1;
    -webkit-transform: translateY(0);
            transform: translateY(0);
  }
}
@-webkit-keyframes button-in {
  0% {
    opacity: 0;
    -webkit-transform: translateY(64px);
            transform: translateY(64px);
  }
  100% {
    opacity: 1;
    -webkit-transform: translateY(0);
            transform: translateY(0);
  }
}
@-webkit-keyframes button-in {
  0% {
    opacity: 0;
    -webkit-transform: translateY(64px);
            transform: translateY(64px);
  }
  100% {
    opacity: 1;
    -webkit-transform: translateY(0);
            transform: translateY(0);
  }
}

.t {
  background: #f5f4f0c9;
  color: #a2a79f96;
  border-top: 2px solid #68fe9a00;
}
.t:not(.block--active) {
  border-bottom: 2px solid #03fd4200;
  box-shadow: 0px 5px 8px -1px rgba(0, 0, 0, 0.8),
      0px 5px 8px 0px rgba(0, 0, 0, 0.14),
      0px 1px 14px 0px rgba(0, 0, 0, 0.12);
}
.t.block--active {
  background: #f6e975de;
  -webkit-box-sizing: inherit;
}
.t .block-content__header {
  background: #35fd7100;
}
.t .block-content__button {
  border-bottom: 2px solid #03fd2d00;
  border-top: 2px solid #68feab00;
}```

【问题讨论】:

  • 寻求代码帮助的问题必须包含重现它所需的最短代码在问题本身中最好在Stack Snippet 中。见How to create a Minimal, Reproducible Example
  • 请澄清您的具体问题或添加其他详细信息以准确突出您的需要。正如目前所写的那样,很难准确地说出你在问什么。

标签: jquery css safari


【解决方案1】:

如果我们的示例对象在所有浏览器中都能正常工作,并且在 Opera 中向前移动了 5 个像素 .opera .object {margin-left: -5px;我们会说}。

也许这会有所帮助

【讨论】:

    猜你喜欢
    • 2023-03-28
    • 1970-01-01
    • 2022-07-14
    • 2016-09-15
    • 1970-01-01
    • 2016-02-10
    • 1970-01-01
    • 2015-07-12
    • 2012-03-18
    相关资源
    最近更新 更多