RError.com

RError.com Logo RError.com Logo

RError.com Navigation

  • 主页

Mobile menu

Close
  • 主页
  • 系统&网络
    • 热门问题
    • 最新问题
    • 标签
  • Ubuntu
    • 热门问题
    • 最新问题
    • 标签
  • 帮助
主页 / 问题 / 582234
Accepted
Bim Bam
Bim Bam
Asked:2020-10-25 00:35:31 +0000 UTC2020-10-25 00:35:31 +0000 UTC 2020-10-25 00:35:31 +0000 UTC

可以用css制作这个动画吗?

  • 772

在此处输入图像描述

有没有可能用CSS制作这样的动画,把某个凸起变成凹陷?如果是,那么用什么?

html
  • 2 2 个回答
  • 10 Views

2 个回答

  • Voted
  1. Best Answer
    Alexandr_TT
    2020-04-03T04:47:47Z2020-04-03T04:47:47Z

    SVG解决方案

    实现这种形状曲线的最简单方法是使用二阶贝塞尔曲线。

    在此处输入图像描述

    从上图可以看出,和题主一样,是可以得到连续帧动画的。为此,您需要更改参数Q x1和y1的坐标

    所以我们为几个由二次贝塞尔曲线组成的补丁写了一些公式。理论就在这里。

    <svg xmlns:xlink="http://www.w3.org/1999/xlink" 
        xmlns="http://www.w3.org/2000/svg"
    	version="1.1" width="300px" height="300px" viewBox="50 -50 300 300" style="border:1px solid red;" >
           
       <path d="M100,100 Q204,200 297,100" style="stroke:blue; stroke-width:3; fill:none;" /> 
       
       
       <path d="M100,100 Q204,167 297,100" style="stroke:blue; stroke-width:3; fill:none;" /> 
     
       
       <path d="M100,100 Q204,100 297,100" style="stroke:blue; stroke-width:3; fill:none;" />  
       
       <path d="M100,100 Q204,50 297,100" style="stroke:blue; stroke-width:3; fill:none;" /> 
       
       <path d="M100,100 Q204,20 297,100" style="stroke:blue; stroke-width:3; fill:none;" /> 
       
       
       <circle cx="100" cy="100"  r="6"  style="fill:none; stroke:orangered; stroke-width:3px;"  />	
       <circle cx="297" cy="100"  r="6"  style="fill:none; stroke:orangered; stroke-width:3px;"  />	
    	
    	</svg>	

    要编写贝塞尔曲线的公式,有一个在线生成器

    在第二阶段,我们通过顺序迭代所有贝塞尔曲线来动画曲线的移动。

    <svg xmlns:xlink="http://www.w3.org/1999/xlink" 
        xmlns="http://www.w3.org/2000/svg"
    	version="1.1" width="350px" height="300px" viewBox="0 50 300 350">
        <defs>
        <linearGradient id="LinGrad"
                        x1="0%" y1="0%"
                        x2="0%" y2="100%"
                        spreadMethod="pad">
          <stop offset="0%"   stop-color="dodgerblue" stop-opacity="1"/>
          <stop offset="75%" stop-color="white" stop-opacity="1"/>
    	  <stop offset="25%" stop-color="green" stop-opacity="1"/>
        </linearGradient>
      </defs>
    
      <rect x="10" y="10" width="350" height="350" rx="10" ry="10" transform="translate(50 0)" style="fill:url(#LinGrad); opacity:0.5;" />      
    
    	  
       <path d="M100,100 Q204,200 297,100" style="stroke:dodgerblue; stroke-width:3; fill:none;" > 
       
        <animate
          attributeName="d"
          dur="2s"
          repeatCount="3"
          values=
           "M100,100 Q204,200 297,100;
            M100,100 Q204,167 297,100;
            M100,100 Q204,100 297,100;
            M100,100 Q204,50 297,100;
            M100,100 Q204,20 297,100"/> 
        </path>
         
       <circle cx="100" cy="100"  r="6"  style="fill:none; stroke:orangered; stroke-width:3px;"  />	
       <circle cx="297" cy="100"  r="6"  style="fill:none; stroke:orangered; stroke-width:3px;"  />	 
      	</svg>

    动画由团队完成

    animate attributeName="d" dur="2s" repeatCount="3"

    在参数values="M100,100 Q204,200 297,100;M100,100 Q204,167 297,100;

    添加二次贝塞尔曲线的所有中间位置,用分号分隔。

    动画二次贝塞尔曲线的另一个例子。

    • 12
  2. Vadim Ovchinnikov
    2020-11-26T01:14:00Z2020-11-26T01:14:00Z

    感谢 .css 的 CSS 动画transform。

    div {
      border-radius: 50%;
      width: 100px;
      height: 100px;
      border-bottom: 2px solid black;
      animation-name: animation;
      animation-duration: 2s;
    }
    
    @keyframes animation {
      from { transform: none; }
      to { transform: rotateX(180deg); }
    }
    <div>
    </div>


    有两个块,CSS 动画和玩border-radius.

    div {
      border-radius: 50%;
      width: 100px;
      height: 100px;
    }
    #top {
      animation-name: top;
      animation-duration: 2s;
    }
    #bottom {
      animation-name: bottom;
      animation-duration: 2s;
      animation-delay: 2s;
    }
    @keyframes top {
      from {
        border-radius: 50%;
        border-bottom: 1px solid black;
        height: 100px;
      }
      to {
        border-radius: 0%;
        border-bottom: 1px solid black;
        height: 50px;
      }
    }
    @keyframes bottom {
      from {
        border-radius: 0%;
        border-top: 1px solid black;
        margin-top: -50px;
      }
      to {
        border-radius: 25%;
        border-top: 1px solid black;
        margin-top: -75px;
      }
      100% {
        border-radius: 50%;
        border-top: 1px solid black;
        margin-top: -100px;
      }
    }
    <div id="top">
    </div>
    
    <div id="bottom">
    </div>

    • 5

相关问题

Sidebar

Stats

  • 问题 10021
  • Answers 30001
  • 最佳答案 8000
  • 用户 6900
  • 常问
  • 回答
  • Marko Smith

    如何停止编写糟糕的代码?

    • 3 个回答
  • Marko Smith

    onCreateView 方法重构

    • 1 个回答
  • Marko Smith

    通用还是非通用

    • 2 个回答
  • Marko Smith

    如何访问 jQuery 中的列

    • 1 个回答
  • Marko Smith

    *.tga 文件的组重命名(3620 个)

    • 1 个回答
  • Marko Smith

    内存分配列表C#

    • 1 个回答
  • Marko Smith

    常规赛适度贪婪

    • 1 个回答
  • Marko Smith

    如何制作自己的自动完成/自动更正?

    • 1 个回答
  • Marko Smith

    选择斐波那契数列

    • 2 个回答
  • Marko Smith

    所有 API 版本中的通用权限代码

    • 2 个回答
  • Martin Hope
    jfs *(星号)和 ** 双星号在 Python 中是什么意思? 2020-11-23 05:07:40 +0000 UTC
  • Martin Hope
    hwak 哪个孩子调用了父母的静态方法?还是不可能完成的任务? 2020-11-18 16:30:55 +0000 UTC
  • Martin Hope
    Qwertiy 并变成3个无穷大 2020-11-06 07:15:57 +0000 UTC
  • Martin Hope
    koks_rs 什么是样板代码? 2020-10-27 15:43:19 +0000 UTC
  • Martin Hope
    user207618 Codegolf——组合选择算法的实现 2020-10-23 18:46:29 +0000 UTC
  • Martin Hope
    Sirop4ik 向 git 提交发布的正确方法是什么? 2020-10-05 00:02:00 +0000 UTC
  • Martin Hope
    Arch ArrayList 与 LinkedList 的区别? 2020-09-20 02:42:49 +0000 UTC
  • Martin Hope
    iluxa1810 哪个更正确使用:if () 或 try-catch? 2020-08-23 18:56:13 +0000 UTC
  • Martin Hope
    faoxis 为什么在这么多示例中函数都称为 foo? 2020-08-15 04:42:49 +0000 UTC
  • Martin Hope
    Pavel Mayorov 如何从事件或回调函数中返回值?或者至少等他们完成。 2020-08-11 16:49:28 +0000 UTC

热门标签

javascript python java php c# c++ html android jquery mysql

Explore

  • 主页
  • 问题
    • 热门问题
    • 最新问题
  • 标签
  • 帮助

Footer

RError.com

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

帮助

© 2023 RError.com All Rights Reserve   沪ICP备12040472号-5