【发布时间】:2025-12-01 20:25:02
【问题描述】:
我在 Safari 12.1 (14607.1.40.1.4) 中将背景颜色转换为透明时遇到问题。
代码不会将背景转换为透明。相反,它在悬停时闪烁或什么都不做。
过渡似乎在 Chrome 和 Firefox 中运行良好。如果
- div 为空
- OR Position:fixed 被移除
- 或目标背景颜色设置为一种颜色(虽然 rgba 透明度不起作用)
<!DOCTYPE html>
<html>
<head>
<style>
body{
background-color:white;
}
.box{
width:200px;
height:100px;
background-color:lightblue;
transition:1s all;
position:fixed;
}
.box:hover{
background-color:transparent;
}
</style>
</head>
<body>
<div class="box">test</div>
</body>
</html>
我希望能够将固定的 div 背景颜色转换为透明。有没有办法让它工作?
【问题讨论】:
-
我有 Safari V. 11.1,当我把它放在 JS Fiddle 中时它似乎工作正常。 jsfiddle.net/f0vkrb7h
-
刚刚在 Browserstack 中测试到 Safari V.12 并且仍然可以正常工作。很抱歉,如果不复制问题就无能为力了。但我会说使用透明可能是它.. 尝试使用 rgba,因为它可以得到尽可能具体的。但我确实看到你说那不起作用。
-
感谢您的测试。也许它与我的设置有关(构建/操作系统/图形卡)......
标签: css safari css-transitions css-position background-color