- objective-c - iOS 5 : Can you override UIAppearance customisations in specific classes?
- iphone - 如何将 CGFontRef 转换为 UIFont?
- ios - 以编程方式关闭标记的信息窗口 google maps iOS
- ios - Xcode 5 - 尝试验证存档时出现 "No application records were found"
我在 Chrome 和 Safari 中有一些奇怪的行为。我有一个缩放的 (transform: scale()
) 容器,里面有视频和其他元素。在某些缩放比例下,具有高 z-index 的绝对定位元素会消失并且不会再次出现。
我该如何解决这个问题?请注意,我不能为视频元素提供负 z-index,我需要使用 overflow: hidden;
。
示例
我做了一个上下缩放最外层容器的例子。在特定比例值下,具有类 .on-top
的元素(和文本 “我应该永远在最前面。”
)消失。再次缩小时突然出现。
示例链接:https://jsfiddle.net/iafiawik/Lcox1ecc/
结论
transform: scale(1.4)
,行为是相同的。问题不存在,如果我:
position: absolute;
从siblings移除到.on-top
(即.below
).content
中移除 overflow: hidden;
.on-top
移动到文档流中的视频标签之后(当然,由于元素的具体原因,这些变通办法在现实中对我都不起作用。我也不能给视频元素一个负的 z-index 并且我需要使用overflow : 隐藏;
.)
社区建议的解决方法(谢谢!)
overflow: hidden;
(我无法移除overflow: hidden;
)浏览器
我在 Chrome (Mac) 和 Safari (Mac) 中看到过这个问题。
更新 1
好像this bug report几乎涵盖了我的问题。但是,它没有提供修复方法。
更新 2
我已经通过提供我对这个问题的解决方案来回答我自己的问题。
更新 3
有很多答案进来,要么修改视频的 z-index
,要么 添加 translateZ
到 .on-top
元素。演示表明,这两种方法都可以解决问题。但是,由于我的 HTML 结构是可视化 HTML 编辑器的输出(长话短说......),我不知道那里会有哪些元素,或者它们是否应该位于视频的前面、下面或旁边。因此,我正在寻找一种不需要更改缩放元素内的单个元素的解决方案。
最佳答案
这看起来像是 Chrome 中的错误。请注意,当您缩放图像时,元素检查器会不断告诉您 #scaled
的大小是 1024x768:
在 Firefox 中的位置
现在,显然,Chrome 使用错误的大小得出 .on-top
的结论完全在.content
之外并由于 overflow hidden 而将其隐藏(它不应该这样做,但显然它正在尝试优化显示在视频上方的任何元素)。示例:
Scale: 1.225
Parent width: 1254.40
Child left: 1254.40 - (100 + 90) * 1.225 = 1021.65
Result: less than 1024 (partially inside)
Scale: 1.230
Parent width: 1259.52
Child left: 1259.52 - (100 + 90) * 1.230 = 1025.82
Result: greater than 1024 (completely outside)
不幸的是,我找不到一个优雅的解决方案。理想情况下,您应该修改 HTML 标记和 CSS,也许将顶部元素与左边缘对齐。作为最后的手段,您可以使用透明边框将元素向左移动更多:
var goalScale = 140;
var startScale = 100;
var currentScale = 100;
var shouldScaleUp = true;
var container = document.getElementById("scaled");
var scaleInfo = document.getElementById("scale-info");
function step() {
container.style.transform = "scale(" + (currentScale / 100) + ")";
scaleInfo.innerText = "Scale: " + (currentScale / 100);
if (currentScale === goalScale) {
shouldScaleUp = false;
}
if (currentScale === startScale) {
shouldScaleUp = true;
}
if (shouldScaleUp) {
currentScale += 0.5;
} else {
currentScale -= 0.5;
}
window.requestAnimationFrame(step);
}
window.requestAnimationFrame(step);
.scale-info {
position: fixed;
left: 0;
top: 0;
}
#scaled {
background: #cccccc;
width: 1024px;
height: 768px;
position: fixed;
left: 200px;
top: 200px;
}
.content {
height: 100%;
overflow: hidden;
position: relative;
margin-left: auto;
margin-right: auto;
background: rgba(34, 34, 56, 0.2);
}
.below {
position: absolute;
width: 300px;
height: 300px;
right: 0px;
top: 100px;
background: purple;
z-index: 1;
opacity: 0.8;
}
.below-2 {
z-index: 3;
right: 100px;
}
.below-3 {
z-index: 4;
right: 400px;
}
.on-top {
position: absolute;
width: 50px;
right: 100px;
top: 150px;
background: pink;
z-index: 5;
padding: 20px;
/* a 200px border moves the element towards left */
border-left: 200px solid transparent;
background-clip: padding-box;
}
.on-top h1 {
font-size: 20px;
}
#video {
position: absolute;
z-index: 4;
width: 1024px;
height: 768px;
background: rgba(0, 0, 0, 0.4);
}
<div id="scale-info"></div>
<div id="scaled">
<div class="content">
<h2 class="below below-1"> I have z-index 1</h2>
<div class="on-top">
<h1> I should always be on top.<br> I have z-index 5</h1>
</div>
<h2 class="below below-2"> I have z-index 3</h2> <video id="video" src="https://www.w3schools.com/html/mov_bbb.mp4"></video>
<h2 class="below below-3"> I have z-index 4</h2>
</div>
</div>
关于javascript - 缩放元素内的视频和 z-index : some divs disappear,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49653475/
所以我正在尝试制作一种命运之轮游戏或刽子手。我有 33 个代表字母的按钮,1 个按钮 = 1 个字母。当用户按下其中一个时,它必须“消失”(变得禁用和不可见)。我在 SceneBuilder 中创建了
我试图让 span 元素在悬停时消失。锻炼效果不佳。 代码:(CSS) .list-item-note { font-size:9px; color:#666; font-s
使用复选框,我想更改两个单选按钮的选中状态。这工作正常,但是当再次更改复选框时,单选按钮选中视觉“消失”,而代码显示它被选中。这是怎么来的? 演示:http://jsfiddle.net/Tz99c/
每当我只是在 Eclipse 中键入一些代码,并单击灰色带状区域上的错误灯泡时,我的代码就跑掉了,我必须关闭文件并重新打开它才能看到我的代码再次编码。有人可以帮我弄清楚如何停止吗?谢谢 最佳答案 我可
我有一个相当奇怪的问题,我无法找到相关文档。我有一个使用 Delphi 内置 TDBMemo 组件的 Delphi 程序,因为该组件需要从数据库中的字段中提取数据。用户还必须能够编辑此信息,即将信息添
我正在尝试使脚本基于输入文件返回AD用户ID,显示名称和组成员身份,并将结果导出到另一个文件。 但是,组成员身份信息似乎在此过程中丢失了。 有任何想法吗? 我当前的脚本: $Result = @()
我有一个背景 Pane ,用于绘制与 BorderPane、VBox 和 HBox 结合使用时不显示的对象。此外,我的 BorderPane 没有正确定位布局(左、下、右)。我尝试过使用多个不同的 P
我在使用自定义 ArrayAdapter 的 ListActivity 中使用我的 ListView 时遇到问题。 当 ListActivity 隐藏(暂停,无论怎样)时,ArrayAdpater 中
看看这张图片 左上角是 Android 汉堡包菜单,但它是白色的。另外,右边是一个搜索放大镜,也是白色的。问题是背景是根据呈现的内容从服务器动态加载的。 是否可以对菜单图标进行着色或提升它们,以便在出
我有一个有点愚蠢的问题。问题是我的程序必须具有从数据库中删除数据的功能。是的,这不是真正的问题。但是我怎样才能删除数据而不会有其他人看到某些内容已被删除的危险。 User Table: U_ID U
我正在编写一个原型(prototype),但遇到了 GUI 问题。我希望 JPanel pCustomer 居中,但这样做它会完全消失。例如,如果我把它放在南方,一切都很好。 import javax
我正在尝试重新创建一个类似于 App Store 故事页脚中使用的 UIVisualEffectView。虽然它看起来很简单,但我无法配置模糊以在白色背景下以相同方式响应。 开箱即用,带有 .ligh
我正在尝试使用 Python 和 SQLite 更新我的用户详细信息。 目的是一次升级我的用户的所有列。 我的代码是: def update(): new_username = input("In
我的工作与网络前端开发人员/websedigner 一样独立,而且我在 Android 手机上使用 HTML5 横幅广告。在 iOS 手机和平板电脑、Chrome 或 Safari 上,它运行完美。但
我以编程方式为我的 View 设置背景图像: UIImageView *backgroundView = [[UIImageView alloc] initWithImage:[UIImage im
假设我有一个这样定义的调试函数: namespace debug { void report(std::string message); } 我能否使用一些编译器技巧,在编译时将每个调用安全地
我在幻灯片中使用响应式断点。在小屏幕上,我一次显示一张幻灯片。在大 2 上(大意味着小于 990 像素) 示例:我将断点设置为在小屏幕上一次显示一张幻灯片,并在大屏幕上禁用 slider 。我有 8
我正在尝试用 Java 实现一个基本的物理引擎,并且使用 JOGL 绑定(bind),以便可以可视化结果。我可以轻松地创建和旋转形状,但在操作视口(viewport)和移动形状时遇到了问题。 我不认为
这个问题不太可能对任何 future 的访客有帮助;它只与一个较小的地理区域、一个特定的时间点或一个非常狭窄的情况相关,通常不适用于全世界的互联网受众。如需帮助使此问题更广泛适用,visit the
我有以下问题:我试图显示一个箭头,如果我从#colorSelect 中删除 overflow:hidden ,它就会起作用。但我需要 overflow:hidden 因为我里面有流元素。 我该如何解决
我是一名优秀的程序员,十分优秀!