- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想使用聚光灯效果,但它似乎只在 Chrome 中有效,在 Firefox 中看起来“刚刚好”,但在 Safari 中无法定位 (x,y,z)。 (其他浏览器未测试)
我尝试了不同的滤镜和原始单位,虽然这有所不同,但 Safari 似乎仍然无法在任何情况下定位照明效果。
为了理解正在发生的事情,我尝试了很多解决方法,包括不同的 userSpaceOnUse/objectBoundingBox 组合和不同的 svg 结构,但从未找到适用于 Safari 的方法。
默认过滤器/原始单位: https://jsfiddle.net/localnerve/y470d52v/
objectBoundingBox 单位: https://jsfiddle.net/localnerve/uyc7o52k/
一张图片也抵得上 1000 个单词(Safari、Chrome、FF)。 Safari 上的聚光灯呈现在右侧的 Canvas 外,并从右侧渗入。
为了显示 Safari 上的聚光灯位置“不正常”,这是我在 Web 检查器中轻推它们以便我可以看到聚光灯渲染:
下面是使用 objectBoundingBox 过滤器和原始单位的代码:
<style>
body {
margin: 0;
padding: 0;
font-family: sans-serif;
font-size: 16px;
color: #fff;
}
* {
transform-origin: 50% 50% 0;
}
.scene-container {
display: flex;
flex-flow: column nowrap;
justify-content: center;
align-items: center;
}
.scene-container.content {
position: relative;
width: 100%;
height: 150vh;
background-image: linear-gradient(hsla(240, 90%, 8%, 1) 0%, 99%, hsla(217,24%,71%,0) 100%);
box-shadow: 0px -10px 20px hsl(240, 90%, 8%);
}
.spot {
height: 100%;
width: 100%;
}
</style>
<body>
<div class="scene-container content">
<h2>Here's a spotlight.</h2>
<svg class="spot" viewBox="0 0 2000 3000" preserveAspectRatio="xMidYMid">
<defs>
<filter x="-0.2" y="-0.2" width="1.4" height="1.4" filterUnits="objectBoundingBox" primitiveUnits="objectBoundingBox" id="spotlight">
<feGaussianBlur in="SourceAlpha" stdDeviation="8" result="blur1"></feGaussianBlur>
<feSpecularLighting result="specOut" in="blur1" specularConstant="1.8" specularExponent="5" lighting-color="#ffffff">
<feSpotLight x="0.5" y="-0.4" z="0.03" pointsAtX="0.5" pointsAtY="0.8" pointsAtZ="0" limitingConeAngle="13.7"></feSpotLight>
</feSpecularLighting>
<feComposite in="SourceGraphic" in2="specOut" operator="arithmetic" k1="0" k2="1" k3="1" k4="0"></feComposite>
</filter>
<clipPath id="spot-clip">
<rect x="-50" y="2840" width="2200" height="200"></rect>
</clipPath>
<filter id="spot-blur">
<feGaussianBlur in="SourceGraphic" stdDeviation="15">
</feGaussianBlur>
</filter>
</defs>
<g transform="translate(0, -175)" filter="url(#spotlight)">
<ellipse cx="50%" cy="95.333%" rx="27%" ry="130" fill="#fff" clip-path="url(#spot-clip)" filter="url(#spot-blur)"></ellipse>
<rect x="25%" y="43.667%" width="50%" height="50%" stroke="peru" stroke-width="3%" stroke-linejoin="round" fill="#000"></rect>
</g>
</svg>
</div>
</body>
非常感谢您提供的任何见解。
最佳答案
在 webkit/Safari 中存在关于光源定位 wrt 变换和 oBB 单位的已知错误。在 webkit/blink 引擎 split 之后,Apple 没有人从 Chrome 团队那里发现这些错误。
https://bugs.webkit.org/show_bug.cgi?id=88877 https://bugs.webkit.org/show_bug.cgi?id=113059
解决方法是不使用转换和 oBB 单元(通过 JavaScript 进行任何动态定位或调整大小)
关于svg - Safari 麻烦定位 SVG feSpotlight 滤镜,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44891524/
我已经习惯了 hibernate ,但我时不时地跌跌撞撞,这是另一个。 我正在努力实现以下目标: @OneToMany @JoinTable(name = "inter_spec",
我的 CakePHP 网站几个月来一直运行良好,直到我今天尝试访问它时,出现以下错误: Warning: include(Cake/bootstrap.php): failed to open str
此代码对其他人有效吗?很长一段时间以来,添加事件监听器都不起作用。 Page Title window.onload = init(); function init
我试图在文本中只留下 a-zA-Z0-9._ : $new_pgname=preg_replace('|(^[a-zA-Z0-9_\.])|s','',$new_pgname); 但是你猜怎么着……对
html: [...][...] js [...]alert(document.getElementById("test").name);[...] 为什么我得到的是“undefined”而不是“te
我正在尝试创建一个实现 main 方法的驱动程序类。它必须创建并测试一个对象来演示所有程序功能。 我认为我已经创建了正确的驱动程序类,但我运行的测试证明我的代码中存在错误,这就是我到目前为止所拥有的。
我正在制作一款扑克游戏,但遇到了一个问题,几乎所有事情都可以按照交易按钮的 actionListener 进行。它应该删除交易按钮并添加一个新的 JTextArea (此文本只是一个占位符)。在那之前
我有一些编程经验,但我对 python 很陌生,我正在尝试弄清楚如何使用和导入 .py 文件中的类而不是 main 。我目前正在使用 netbeans,运行 CPython 3.2.1。 根据我现在的
好吧,我不知道发生了什么。我对 iOS 还比较陌生,所以我的调试技能还达不到他们需要的水平。我有一个文本字段工作得很好,直到我在我的应用程序中做了一些更改,这些更改与文本字段没有任何关系(至少我认为它
你好社区我有以下问题。 我的 list 文件如下所示。
我正在使用Drupal2Wordpress plugin将我的内容从 Drupal 传输到 WP,但我在尝试开始该过程时收到此错误:无法连接到 Drupal 数据库。 这是MySQL的日志: 1504
我有以下代码。它编译得很好,但它告诉我字符串是“E#^$$@$$$$$$$”。有什么想法吗? ifstream InFile(Filename); if (!InFile) return fa
我正在为类(class)的期末考试做准备,并且正在尝试重做作业问题。这是我第一次获得零学分的其中之一。 此练习的目标是创建一个 URL,该 URL 将指向包含以下 HTML 的页面,而不是显示预期的协
我开始研究套接字,但遇到了麻烦!我做错了什么? 服务器: /* server.c */ /* ############### INCLUDES ############### */ #include
我正在尝试制作一个逐行读取文件然后将读取的行放入链表的程序,我的问题是将字符串添加到列表中。看代码,在else测试中你可以看到我的问题。 #include #include struct list_e
我是 WordPress 新手,正在为 friend 编辑网站。我正在尝试向站点添加 RSS 提要,因此我编辑了 header.php 文件(这就是它的去向)。 我还编辑了 CSS,然后使用 File
我将向您展示 2 个场景(注意 d=damping factor=0.5) 第一种情况:假设有 4 个节点 A, B, C, D : B、C、D 链接到 A。 PageRank 是:PR(A)=0.5
我无法理解 mem_fun_ref。我必须承认,我通常将仿函数用于此类事情,因为它们可以内联以提高速度和利润。但是,这段代码不会成为瓶颈,所以我想尝试一下。 这是我想做的一个例子。我知道还有其他方法可
尝试使用 AudioClip 编译 applet 时出现预期标识符错误。我计划将其添加到 JFrame,并希望让 AudioClip 循环播放。 import java.applet.*; impor
我正在尝试开始使用 node.js,但我绝不是高级程序员。除了检查我的 ip,我从未使用过 cmd。 我的问题是我不知道将文件保存在哪里,以及如何使用 node.js 从 cmd 运行它们。我发现的教
我是一名优秀的程序员,十分优秀!