悬停效果:CSS 动画或网页动画
问题:
SMIL 的 animate 标签已弃用,CSS 悬停过渡需要更改
解决方案:
去掉set标签,在element_tpl:hover伪类中添加CSS:
<code class="css">.element_tpl:hover { stroke-opacity: 0.5; }</code>
缩放效果更改
问题:
在提交的更改时对元素进行动画缩放几次。
解决方案:
考虑以下选项:
- CSS 动画: 使用 CSS 关键帧实现缩放:
<code class="css">@keyframes scale-animation { 0% { transform: scale(1); } 50% { transform: scale(1.12); } 100% { transform: scale(1); } }</code>
然后将动画应用到元素:
<code class="css">.element_tpl { animation: scale-animation 0.5s infinite alternate; }</code>
- 网页动画:使用网页动画 API 以编程方式控制缩放:
<code class="javascript">// Create a new animation const animation = document.timeline.addAnimation(); // Define keyframes const keyframes = [ { transform: 'scale(1)', offset: 0 }, { transform: 'scale(1.12)', offset: 0.5 }, { transform: 'scale(1)', offset: 1 } ]; // Apply keyframes to the animation animation.effect = keyframes; // Target the element animation.target = document.querySelector('.element_tpl');</code>
单击时向上和向下缩放
问题:
让元素在点击时以动画方式放大和缩小。
解决方案:
- CSS 过渡: 使用 CSS 过渡来触发 mousedown 和 mouseup 事件的比例变化:
<code class="css">.element_tpl { transition: transform 0.2s; } .element_tpl:active { transform: scale(1.1); }</code>
- 网页动画: 使用网页动画用于处理点击事件并相应缩放元素的 API:
<code class="javascript">// Add event listener document.querySelector('.element_tpl').addEventListener('click', (event) => { // Create a new animation const animation = document.timeline.addAnimation(); // Define keyframes const keyframes = [ { transform: 'scale(1)', offset: 0 }, { transform: 'scale(1.1)', offset: 0.2 }, { transform: 'scale(1)', offset: 0.4 }, ]; // Apply keyframes to the animation animation.effect = keyframes; // Target the element animation.target = event.target; });</code>
保存 SMIL 动画
问题:
将 SMIL 动画传输到 CSS 或网页动画。
解决方案:
使用 Eric Willigers 创建的 SMIL polyfill:https://github.com/ericwilligers/svg-animation。这个polyfill将SMIL动画转换为Web动画,提供了另一种实现它们的方法。
以上是如何用 CSS 或 Web 动画替换已弃用的 SMIL 动画?的详细内容。更多信息请关注PHP中文网其他相关文章!

对于Astro,我们可以在构建过程中生成大部分网站,但是有一小部分服务器端代码可以使用Fuse.js之类的搜索功能来处理搜索功能。在此演示中,我们将使用保险丝搜索一组个人“书签”


热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

Video Face Swap
使用我们完全免费的人工智能换脸工具轻松在任何视频中换脸!

热门文章

热工具

适用于 Eclipse 的 SAP NetWeaver 服务器适配器
将Eclipse与SAP NetWeaver应用服务器集成。

VSCode Windows 64位 下载
微软推出的免费、功能强大的一款IDE编辑器

SecLists
SecLists是最终安全测试人员的伙伴。它是一个包含各种类型列表的集合,这些列表在安全评估过程中经常使用,都在一个地方。SecLists通过方便地提供安全测试人员可能需要的所有列表,帮助提高安全测试的效率和生产力。列表类型包括用户名、密码、URL、模糊测试有效载荷、敏感数据模式、Web shell等等。测试人员只需将此存储库拉到新的测试机上,他就可以访问到所需的每种类型的列表。

记事本++7.3.1
好用且免费的代码编辑器

安全考试浏览器
Safe Exam Browser是一个安全的浏览器环境,用于安全地进行在线考试。该软件将任何计算机变成一个安全的工作站。它控制对任何实用工具的访问,并防止学生使用未经授权的资源。