简体   繁体   English

Position 固定在 safari 上被切断

[英]Position fixed being cut off on safari

I have a fixed position tooltip that works in all browsers except Safari.我有一个固定的 position 工具提示,它适用于除 Safari 之外的所有浏览器。 In safari, the tooltip is being cut off by the parent's container which has properties of overflow: scroll在 safari 中,工具提示被具有overflow: scroll

Any ideas on how I can fix this?关于如何解决这个问题的任何想法?

This is the screenshot of how it's supposed to look like:这是它应该是什么样子的屏幕截图:

这是它应该是什么样子的屏幕截图

This is how it looks on safari:这是它在 safari 上的外观:

在此处输入图像描述

These are the properties for the tooltip:这些是工具提示的属性:

        .announcement {
          position: fixed;
          width: 3.1rem;
          height: 3.1rem;
          background-image: url("./../assets/icons/announcement-alert-right.svg");
          background-size: cover;
          margin: 0 0 0 -2.8rem;
          z-index: 1;

          &:hover {
            margin: -3.6rem 0 0 -14.8rem;
            width: 15.3rem;
            height: 6.7rem;
            background-image: url("./../assets/icons/announcement-profile.svg");
          }

          @media screen and (max-width: $desktop) {
            display: none;
          }
        }

This is the parent's perspective:这是家长的观点:

.profile {
  position: fixed;
  z-index: map-get($zindex, sidebar);
  right: 0;
  width: 15%;
  height: 100%;
  transition: 0.5s;
  padding: 3rem;
  box-shadow: 0 1.5rem 3rem $color-shadow;
  background-color: $color-white;  
  overflow: scroll;
  -ms-overflow-style: none;
  scrollbar-width: none;

  &::-webkit-scrollbar {
    display: none;
  }
}

I've tried several different fixes such as: -webkit-transform: translateZ(0);我尝试了几种不同的修复方法,例如: -webkit-transform: translateZ(0); transform: translate3d(0, 0, 0); -webkit-transform: translate3d(0, 0, 0); z-index:9999 !important) and none of them works. z-index:9999 !important)并且它们都不起作用。

Any help would be much appreciated!任何帮助将非常感激! Thanks!谢谢!

Without knowing your html code i speculated that the parent container and the tool tip element are not at the same level so even if you increase z-index value it won't change.在不知道您的 html 代码的情况下,我推测父容器和工具提示元素不在同一级别,因此即使您增加 z-index 值也不会改变。 Place the element at the same level that would work.Something like this将元素放在可以工作的同一级别。像这样的东西

<parent-container>
//parent content
</parent-container>
<tooltip-element>
//tooltip-content
</tooltip-element> //same level

Check the parents' properties and the overlapping element's properties.检查父元素的属性和重叠元素的属性。 Some of them has a position or az index value that is blocking it from your desired behavior他们中的一些人有一个 position 或 az 索引值,它阻止了你想要的行为

I bet is that maybe you will need to split up the position: fixed and overflow tags across two nested div classes in Safari?我敢打赌,也许您需要在 Safari 中的两个嵌套 div 类中拆分position: fixedoverflow标签? I know this could be a bit annoying and inconvenient, but then that way - I don't think that the z-index will be blocked off...我知道这可能有点烦人和不方便,但是那样 - 我不认为z-index会被封锁......

HTML: HTML:

<div class="wrapper1">
  <div class="wrapper2">
    <div class="inner">
       /* Stuff inside here */  
    </div>
  </div>
</div>

CSS: CSS:

.wrapper {
  ...
  position: fixed;
  ...
}

.wrapper2 {
  ...
  overflow: hidden;
  position: absolute;
  ...
}

I wouldn't have thought that the overflow: scroll would affect any of the z-index properties but we'll see.我不会想到overflow: scroll会影响任何z-index属性,但我们会看到。 Good luck on finding a solution, hopefully I've somewhat helped!祝你好运找到解决方案,希望我有所帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM