- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在 svg 格式的 stoke 动画中遇到了一个小问题。我有一个动画:CSS 中的 stroke-dashoffset 属性。
但是悬停时的标志并没有完全完成所有的动画。该 Logo 应该制作动画以用线条建立自己。动画工作但不完全。
检查我的 jsfiddle 以查看代码的问题。 https://jsfiddle.net/ytkL4b5d/HTML
<div id="logo">
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 733.9 500" style="enable-background:new 0 0 733.9 500;" xml:space="preserve">
<polygon class="logo" id="XMLID_56_" points="193.7,39.2 193.7,454.2 228.4,454.2 228.4,454.2 469,454.2 469,419.5 228.4,419.5 228.4,131.2
366.9,288.8 505.2,129.9 505.2,454.2 539.9,454.2 539.9,37.2 366.7,236.1 "/>
<path class="logo" id="XMLID_101_" d="M47.3,85.2c0,16.8,2.4,33,4.8,49.8c2.4,16.8,4.8,33.6,4.8,50.4c0,21-6,44.4-48.6,44.4v30.6
c42.6,0,48.6,25.8,48.6,44.4c0,16.2-2.4,32.4-4.8,48.6c-2.4,16.2-4.8,33-4.8,49.2c0,60.6,37.2,82.2,87,82.2h12.6v-33h-10.8
c-33.6,0-47.4-18.6-47.4-52.2c0-14.4,1.8-28.2,4.2-43.2c2.4-14.4,4.2-29.4,4.2-45.6c0.6-38.4-16.2-58.8-43.2-65.4v-1.2
c27-7.2,43.8-26.4,43.2-64.8c0-16.2-1.8-30.6-4.2-45.6c-2.4-14.4-4.2-28.8-4.2-42.6c0-32.4,12-51.6,47.4-51.6h10.8v-33h-12.6
C83.3,6.6,47.3,30,47.3,85.2z"/>
<path class="logo" id="XMLID_102_" d="M675.5,185.4c0-16.8,2.4-33.6,4.8-50.4c2.4-16.8,4.8-33,4.8-49.8c0-55.2-36.6-78.6-87.6-78.6h-12v33h10.8
c34.8,0.6,47.4,19.2,47.4,51.6c0,13.8-2.4,28.2-4.2,42.6c-2.4,15-4.8,29.4-4.8,45.6c0,38.4,16.8,57.6,43.2,64.8v1.2
c-26.4,6.6-43.2,27-43.2,65.4c0,16.2,2.4,31.2,4.8,45.6c1.8,15,4.2,28.8,4.2,43.2c0,33.6-14.4,51.6-48,52.2h-10.2v33h12.6
c49.2,0,87-21.6,87-82.2c0-16.2-2.4-33-4.8-49.2c-2.4-16.2-4.8-32.4-4.8-48.6c0-18.6,6-44.4,48.6-44.4v-30.6
C681.5,229.8,675.5,206.4,675.5,185.4z"/>
</svg>
</div>
CSS(scss):
#logo{
width:120px;
height:auto;
float:left;
margin-left:20px;
margin-top:0px;
.logo{
width: 120px;
height: auto;
padding: 5px;
fill: #000;
animation: dashreverse 5s ease;
-webkit-transition: all 400ms ease-in-out;
-moz-transition: all 400ms ease-in-out;
-ms-transition: all 400ms ease-in-out;
-o-transition: all 400ms ease-in-out;
transition: all 400ms ease-in-out;
}
&:hover{
.logo{
fill: transparent;
stroke: #000;
stroke-width: 4px;
stroke-linecap: round;
stroke-linejoin: round;
stroke-dasharray: 1000;
stroke-dashoffset: 0;
transition: .2s;
animation: dash 4s ease;
}
}
}
@keyframes dash {
from {
stroke-dashoffset: 1000;
}
to {
stroke-dashoffset: 0;
}
}
**我认为问题可能在于我的 svg 是如何制作的。我使用 Illustrator 来制作它并生成一个 svg。
最佳答案
问题是您的 dasharray 长度为 1000。要使动画正常工作,您使用的长度必须与元素的路径长度相匹配。
您的元素的路径长度远大于 1000。“M”的长度为 2977,而两个括号的长度分别为 1277 和 1276。
如果您将 dasharray 和 start dashoffset 设置为这三个长度中最长的一个,动画将会完成。
.logo{
...
stroke-dasharray: 2977;
...
}
和
@keyframes dash {
from {
stroke-dashoffset: 2977;
}
to {
stroke-dashoffset: 0;
}
}
https://jsfiddle.net/ytkL4b5d/1/
然而,这意味着括号比“M”更短,完成得更快。如果你不喜欢那样,你可以有两个动画。长的 M 和短的 1277 括号。
关于css - 动画 svg 描边不完整,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31756893/
目标 我正在尝试创建一个 SVG 图标以添加到图标字体文件中。 进展 我已经创建了一个 SVG 图标,它以内嵌的形式完美呈现并作为 img 问题 当我上传它以添加到我的图标字体时,同时使用 Icomo
我有一个带边框的动态宽度/高度 div。里面是一个绝对定位的按钮,位于底部的中心,与父 div 的边框重叠。我想让它看起来像边框在重叠按钮之前停止几个像素。一项要求是保持一切动态,例如,如果按钮的宽度
Unity UGUI的Outline(描边)组件的介绍及使用 1. 什么是Outline(描边)组件? Outline(描边)组件是Unity UGUI中的一种特效组件,用于给UI元素添
我需要动态创建这样的大纲: 不是针对一个 CCSprite,而是针对一个 CCNode 中的多个动画 CCSprite。我在想: 将 CCNode 的内容复制到纹理(如 AS3 中的 canvasBi
我正在寻找一种使用 HTML Canvas 对笔划进行动画绘制的方法。 是否有任何预定义的内容可以让您执行此操作? 最佳答案 我不知道任何预定义的解决方案。也许在图书馆里。像raphael 但是如果您
我正在尝试添加一些动画来更改 Canvas 弧的 endAngle,如下所示,但它不起作用。我怎样才能做到这一点? var steps =30; var canvas = document.getEl
我有一个具有以下背景的按钮: 我需要在代码中
我有子类 NSImageView,我想用圆角画一个边框。它可以工作,但我还需要剪掉图像的角。 请看我的截图: 我创建了这段代码来绘制边框/角。 - (void)drawRect:(NSRect)dir
查看positionly.com使用的图表:https://www.dropbox.com/s/kz9ksagctf7zpaa/Screenshot%202015-12-18%2010.31.03.p
我刚刚开始使用 Apache PDFBox,对于应用于文本和线条时描边、非描边和填充的含义,我完全感到困惑。 请有人向我指出一个引用/指南,其中解释了这些术语的含义(对于初学者)以及它们之间的区别。
我正在使用 svg/d3 创建一个由“矩形”元素组成的图表。 为每个矩形(仅在矩形顶部)添加部分边框/描边的最佳方法是什么? 谢谢 最佳答案 我认为 SVG 不支持仅对矩形或路径的部分进行描边 - 描
我正在学习 Canvas ,我的目标是徒手绘画。每个在线示例都说我应该在我的 onmousemove 中调用 stroke()。如果我的颜色 strokeStyle 具有 100% 的不透明度,这将按
我想在用户键入时向可编辑的 UITextView 文本添加轮廓或描边。完全像模因:http://t.qkme.me/3oi5rs.jpg 我必须使用 UITextView 因为我需要多行支持。我已经尝
如何在 material-ui 图标周围添加颜色轮廓? 有这个 看起来更像这样? 我尝试过中风和 webkit-stroke,但没有任何运气。它在整个隐形盒子周围放置了一个边框。 最佳答案 在 Rea
我在 drawRect 中绘制了一个形状,它存储在 CGMutablePathRef (shapeMutablePath) 中。每次调用 drawRect 时,形状都会被拉伸(stretch)以适应屏
我已经使用以下代码向我的 map 添加了一个叠加层: func mapView(mapView: MKMapView!, rendererForOverlay overlay: MKOverlay!)
我有一个 CAShapeLayer,它有一个不透明的描边和一个透明的填充。然后我想调用 myContext.drawRadialGradient,但是将这个径向渐变剪辑到我的形状层的笔划。目前,我正在
我已将我的 SVG 图像设置为 div 的背景。现在我想每隔 x 秒用 jQuery 更改特定路径的笔画。我看过一个示例 ( click me ),其中基本上完成了此操作。 到目前为止,这是我的 jQ
我正在努力寻找一种快速绘制(和填充)贝塞尔曲线路径的方法。这是我认为行得通但行不通的方法。 var myBezier = UIBezierPath() myBezier.moveToPoint(CGP
我尝试了很多很多方法在图像周围画一个黑色轮廓。 这是我想要的结果示例: 有人可以告诉我我应该怎么做吗?或者给我举个例子? 编辑:我卡在这里:有人可以帮我完成它吗?我所做的是在带有阴影的白色下制作另一个
我是一名优秀的程序员,十分优秀!