我刚找到一个GitHub Repo , 上面有一个很酷的 button 的 Spark 动画,但适用于安卓系统。
这是Animation :
但是,我想在我的网站上使用它,所以我开始自己设计它。
首先,我broke the gif down by frames .然后,通过这些点,我制定了路线图,这就是我在编写代码时所遵循的:
scale()下来。 scale() 一个橙色的小圆圈逐渐覆盖了星星起来。 background-color (白色,在这种情况下),也逐渐覆盖前一个圆圈 scale()起来。 scale()再次出现(因此,我必须增加 z-index ),这次是橙色(表示其选定状态)。 svg {
position: absolute;
top: 0;
width: 100px;
height: 100px;
transition: 0.5s;
fill:gray;
}
svg:hover {
animation: up-svg 1s;
fill: darkorange;
z-index: 1;
}
svg:hover~.svg {
animation: up-one 0.5s;
display: block;
}
svg:hover~.svg1 {
animation: up-two 1s;
display: block;
}
.svg {
position: absolute;
top: 0;
border-radius: 50%;
width: 100px;
height: 100px;
background-color: orange;
display: none;
transform: scale(0.9);
transition: 0.5s;
}
.svg1 {
position: absolute;
top: 0;
border-radius: 50%;
width: 100px;
height: 100px;
background-color: white;
display: none;
transition: 0.5s;
}
@keyframes up-one {
0% {
transform: scale(0);
}
40% {
transform: scale(0);
}
100% {
transform: scale(0.9);
}
}
@keyframes up-two {
0% {
transform: scale(0);
}
37.5% {
transform: scale(0);
}
50% {
transform: scale(0.25);
}
62.5% {
transform: scale(0.5);
}
75% {
transform: scale(0.75);
}
87.5% {
transform: scale(0.9);
}
100% {
transform: scale(1);
}
}
@keyframes up-svg {
0% {
transform: scale(1);
fill: gray;
z-index: 0;
}
70% {
transform: scale(0);
fill: darkorange;
z-index: 1;
}
100% {
transform: scale(1);
fill: darkorange;
z-index: 1;
}
} <svg id="s-tt" class="s-icon" role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M23.954 4.569c-.885.389-1.83.654-2.825.775 1.014-.611 1.794-1.574 2.163-2.723-.951.555-2.005.959-3.127 1.184-.896-.959-2.173-1.559-3.591-1.559-2.717 0-4.92 2.203-4.92 4.917 0 .39.045.765.127 1.124C7.691 8.094 4.066 6.13 1.64 3.161c-.427.722-.666 1.561-.666 2.475 0 1.71.87 3.213 2.188 4.096-.807-.026-1.566-.248-2.228-.616v.061c0 2.385 1.693 4.374 3.946 4.827-.413.111-.849.171-1.296.171-.314 0-.615-.03-.916-.086.631 1.953 2.445 3.377 4.604 3.417-1.68 1.319-3.809 2.105-6.102 2.105-.39 0-.779-.023-1.17-.067 2.189 1.394 4.768 2.209 7.557 2.209 9.054 0 13.999-7.496 13.999-13.986 0-.209 0-.42-.015-.63.961-.689 1.8-1.56 2.46-2.548l-.047-.02z"/></svg>
<div class="svg"></div>
<div class="svg1"></div>hover属性(以便可以一次又一次地看到动画而无需重新加载)现在直到动画完成。最佳答案
这是我的想法,我将只依赖 CSS 和少量元素。我将单独详细说明每个部分,然后将其组合成一个动画。
对于图标部分(星号),我也会这样做,但我可能会考虑使用 grayscale过滤器具有适用于任何元素和任何颜色的通用效果。
.magic i{
color:red;
filter:grayscale(100%);
}
.magic:hover i{
animation:change 1s forwards;
}
@keyframes change{
50% {
transform:scale(0);
filter:grayscale(100%);
}
51% {
filter:grayscale(0%);
}
100% {
transform:scale(1);
filter:grayscale(0%);
}
} <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.7.1/css/all.css">
<span class="magic">
<i class="fas fa-star fa-5x"></i>
</span>0而且我们只有边界,因此它将是一个完整的圆圈。然后我们简单地减少边框的厚度,同时保持整体宽度不变。所以我们会这样做:0和边框宽度0 .circle {
display:inline-block;
width:0px;
height:0px;
border-radius:50%;
border-color:orange;
border-style:solid;
border-width:0px;
box-sizing:border-box;
}
body:hover .circle {
animation:change 1s forwards;
}
@keyframes change {
50% {
border-width:25px;
}
100% {
border-width:0;
width:50px;
height:50px;
}
}
body {
min-height:100px;
} <span class="circle"></span>.circle {
display:inline-block;
width:50px;
height:50px;
border-radius:50%;
border-color:orange;
border-style:solid;
border-width:25px;
transform:scale(0);
box-sizing:border-box;
}
body:hover .circle {
animation:change 1s linear forwards;
}
@keyframes change {
50% {
transform:scale(1);
border-width:25px;
}
100% {
transform:scale(1);
border-width:0;
}
}
body {
min-height:100px;
} <span class="circle"></span>.circle {
display:inline-block;
width:50px;
height:50px;
border-radius:50%;
border-color:orange;
border-style:solid;
border-width:25px;
transform:scale(0);
box-sizing:border-box;
transition:
transform 0.5s,
border-width 0.5s 0.5s;
}
body:hover .circle {
border-width:0;
transform:scale(1);
}
body {
min-height:100px;
} <span class="circle"></span>radial-gradient和规模。这个想法是在一个元素内创建带有渐变的小圆圈,并使用比例来创建扩展效果。.small {
display:inline-block;
width:100px;
height:100px;
background:
/*4 reds*/
radial-gradient(circle,red 50%,transparent 60%),
radial-gradient(circle,red 50%,transparent 60%),
radial-gradient(circle,red 50%,transparent 60%),
radial-gradient(circle,red 50%,transparent 60%),
/*4 oranges*/
radial-gradient(circle,orange 50%,transparent 60%),
radial-gradient(circle,orange 50%,transparent 60%),
radial-gradient(circle,orange 50%,transparent 60%),
radial-gradient(circle,orange 50%,transparent 60%);
background-size:16px 16px;
background-position:
calc(50% - 30px) calc(50% - 30px),
calc(50% + 30px) calc(50% - 30px),
calc(50% - 30px) calc(50% + 30px),
calc(50% + 30px) calc(50% + 30px),
calc(50% + 0px) calc(50% + 40px),
calc(50% + 40px) calc(50% + 0px),
calc(50% - 40px) calc(50% + 0px),
calc(50% + 0px) calc(50% - 40px);
background-repeat:no-repeat;
border-radius:50%;
} <span class="small"></span>background-position 工作原理的更多详细信息:https://stackoverflow.com/a/51734530/8620333)。您只需要根据需要调整圆圈的大小、位置和颜色。.small {
display:inline-block;
width:100px;
height:100px;
background:
/*4 reds*/
radial-gradient(circle,red 50%,transparent 60%),
radial-gradient(circle,red 50%,transparent 60%),
radial-gradient(circle,red 50%,transparent 60%),
radial-gradient(circle,red 50%,transparent 60%),
/*4 oranges*/
radial-gradient(circle,orange 50%,transparent 60%),
radial-gradient(circle,orange 50%,transparent 60%),
radial-gradient(circle,orange 50%,transparent 60%),
radial-gradient(circle,orange 50%,transparent 60%);
background-size:16px 16px;
background-position:
calc(50% - 30px) calc(50% - 30px),
calc(50% + 30px) calc(50% - 30px),
calc(50% - 30px) calc(50% + 30px),
calc(50% + 30px) calc(50% + 30px),
calc(50% + 0px) calc(50% + 40px),
calc(50% + 40px) calc(50% + 0px),
calc(50% - 40px) calc(50% + 0px),
calc(50% + 0px) calc(50% - 40px);
background-repeat:no-repeat;
border-radius:50%;
transform:scale(0);
transition:transform 0.5s,opacity 0.4s 0.4s;
}
body {
min-height:200px;
}
body:hover .small {
transform:scale(1);
opacity:0;
} <span class="small"></span>background-size 来减小圆圈。 ..small {
display:inline-block;
width:100px;
height:100px;
background:
/*4 reds*/
radial-gradient(circle,red 50%,transparent 60%),
radial-gradient(circle,red 50%,transparent 60%),
radial-gradient(circle,red 50%,transparent 60%),
radial-gradient(circle,red 50%,transparent 60%),
/*4 oranges*/
radial-gradient(circle,orange 50%,transparent 60%),
radial-gradient(circle,orange 50%,transparent 60%),
radial-gradient(circle,orange 50%,transparent 60%),
radial-gradient(circle,orange 50%,transparent 60%);
background-size:16px 16px; /*at least 2x7px */
background-position:
calc(50% - 30px) calc(50% - 30px),
calc(50% + 30px) calc(50% - 30px),
calc(50% - 30px) calc(50% + 30px),
calc(50% + 30px) calc(50% + 30px),
calc(50% + 0px) calc(50% + 40px),
calc(50% + 40px) calc(50% + 0px),
calc(50% - 40px) calc(50% + 0px),
calc(50% + 0px) calc(50% - 40px);
background-repeat:no-repeat;
border-radius:50%;
transform:scale(0);
transition:transform 0.5s,opacity 0.4s 0.4s,background-size 0.5s 0.4s;
}
body {
min-height:200px;
}
body:hover .small {
transform:scale(1);
opacity:0;
background-size:0 0;
} <span class="small"></span>.magic {
display:inline-block;
margin:50px;
position:relative;
}
.magic i{
color:orange;
filter:grayscale(100%);
position:relative;
}
.magic:hover i{
animation:change 1s forwards;
}
@keyframes change{
50% {
transform:scale(0);
filter:grayscale(100%);
}
51% {
filter:grayscale(0%);
}
100% {
transform:scale(1);
filter:grayscale(0%);
}
}
/**/
.magic:before {
content:"";
position:absolute;
top:calc(50% - 45px);
left:calc(50% - 45px);
width:90px;
height:90px;
border-radius:50%;
border-color:orange;
border-style:solid;
border-width:45px;
transform:scale(0);
box-sizing:border-box;
}
.magic:hover::before {
transition:
transform 0.5s,
border-width 0.5s 0.5s;
border-width:0;
transform:scale(1);
}
/**/
.magic::after {
content:"";
position:absolute;
width:160px;
height:160px;
left:calc(50% - 80px);
top:calc(50% - 80px);
background:
/*4 reds*/
radial-gradient(circle,red 50%,transparent 60%),
radial-gradient(circle,red 50%,transparent 60%),
radial-gradient(circle,red 50%,transparent 60%),
radial-gradient(circle,red 50%,transparent 60%),
/*4 oranges*/
radial-gradient(circle,orange 50%,transparent 60%),
radial-gradient(circle,orange 50%,transparent 60%),
radial-gradient(circle,orange 50%,transparent 60%),
radial-gradient(circle,orange 50%,transparent 60%);
background-size:16px 16px;
background-position:
calc(50% - 50px) calc(50% - 50px),
calc(50% + 50px) calc(50% - 50px),
calc(50% - 50px) calc(50% + 50px),
calc(50% + 50px) calc(50% + 50px),
calc(50% + 0px) calc(50% + 70px),
calc(50% + 70px) calc(50% + 0px),
calc(50% - 70px) calc(50% + 0px),
calc(50% + 0px) calc(50% - 70px);
background-repeat:no-repeat;
border-radius:50%;
transform:scale(0);
}
.magic:hover:after {
transform:scale(1);
opacity:0;
background-size:0 0;
transition:
transform 0.5s 0.5s,
opacity 0.4s 0.9s,
background-size 0.5s 0.9s;
} <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.7.1/css/all.css">
<span class="magic">
<i class="fas fa-star fa-5x"></i>
</span>
<span class="magic">
<i class="fas fa-user fa-5x"></i>
</span>.magic {
display:inline-block;
margin:50px;
position:relative;
}
.magic i{
color:orange;
filter:grayscale(100%);
}
.magic:hover i{
animation:change 1s forwards;
}
@keyframes change{
50% {
transform:scale(0);
filter:grayscale(100%);
}
51% {
filter:grayscale(0%);
}
100% {
transform:scale(1);
filter:grayscale(0%);
}
}
/**/
.magic:before {
content:"";
position:absolute;
top:calc(50% - 45px);
left:calc(50% - 45px);
width:90px;
height:90px;
border-radius:50%;
border-color:orange;
border-style:solid;
border-width:45px;
transform:scale(0);
box-sizing:border-box;
}
.magic:hover::before {
border-width:0;
transform:scale(1);
transition:
transform 0.5s,
border-width 0.5s 0.5s;
}
/**/
.magic::after,
.magic i::after{
content:"";
position:absolute;
width:160px;
height:160px;
left:calc(50% - 80px);
top:calc(50% - 80px);
background:
/*4 reds*/
radial-gradient(circle,red 50%,transparent 60%),
radial-gradient(circle,red 50%,transparent 60%),
radial-gradient(circle,red 50%,transparent 60%),
radial-gradient(circle,red 50%,transparent 60%),
/*4 oranges*/
radial-gradient(circle,orange 50%,transparent 60%),
radial-gradient(circle,orange 50%,transparent 60%),
radial-gradient(circle,orange 50%,transparent 60%),
radial-gradient(circle,orange 50%,transparent 60%);
background-size:16px 16px;
background-position:
calc(50% - 50px) calc(50% - 50px),
calc(50% + 50px) calc(50% - 50px),
calc(50% - 50px) calc(50% + 50px),
calc(50% + 50px) calc(50% + 50px),
calc(50% + 0px) calc(50% + 70px),
calc(50% + 70px) calc(50% + 0px),
calc(50% - 70px) calc(50% + 0px),
calc(50% + 0px) calc(50% - 70px);
background-repeat:no-repeat;
border-radius:50%;
transform:scale(0);
}
.magic i::after {
background-size:10px 10px;
transform:rotate(10deg) scale(0);
}
.magic:hover:after {
transform:scale(1);
opacity:0;
background-size:0 0;
transition:transform 0.5s 0.5s,opacity 0.4s 0.9s,background-size 0.5s 0.9s;
}
.magic:hover i:after {
transform:rotate(10deg) scale(1);
opacity:0;
background-size:0 0;
transition:transform 0.5s 0.5s,opacity 0.4s 0.9s,background-size 0.5s 0.9s;
}
/**/ <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.7.1/css/all.css">
<span class="magic">
<i class="fas fa-star fa-5x"></i>
</span>
<span class="magic">
<i class="fas fa-user fa-5x"></i>
</span>.magic {
display:inline-block;
margin:50px;
position:relative;
--r:45px;
}
.magic i{
color:orange;
filter:grayscale(100%);
}
.magic:hover i{
animation:change 1s forwards;
}
@keyframes change{
50% {
transform:scale(0);
filter:grayscale(100%);
}
51% {
filter:grayscale(0%);
}
100% {
transform:scale(1);
filter:grayscale(0%);
}
}
/**/
.magic:before {
content:"";
position:absolute;
top:calc(50% - var(--r));
left:calc(50% - var(--r));
width:calc(2*var(--r));
height:calc(2*var(--r));
border-radius:50%;
border:solid orange var(--r);
transform:scale(0);
box-sizing:border-box;
}
.magic:hover::before {
border-width:0;
transform:scale(1);
transition:
transform 0.5s,
border-width 0.5s 0.5s;
}
/**/
.magic::after,
.magic i::after{
content:"";
position:absolute;
width: calc(4*var(--r));
height:calc(4*var(--r));
left:calc(50% - 2*var(--r));
top: calc(50% - 2*var(--r));
--c1:radial-gradient(circle,red 50% ,transparent 60%);
--c2:radial-gradient(circle,orange 50%,transparent 60%);
background:
/*4 reds*/
var(--c1),var(--c1),var(--c1),var(--c1),
/*4 oranges*/
var(--c2),var(--c2),var(--c2),var(--c2);
background-size:calc(var(--r)/3) calc(var(--r)/3);
background-position:
calc(50% - var(--r)) calc(50% - var(--r)),
calc(50% + var(--r)) calc(50% - var(--r)),
calc(50% - var(--r)) calc(50% + var(--r)),
calc(50% + var(--r)) calc(50% + var(--r)),
calc(50% + 0px) calc(50% + var(--r)*1.414),
calc(50% + var(--r)*1.414) calc(50% + 0px),
calc(50% - var(--r)*1.414) calc(50% + 0px),
calc(50% + 0px) calc(50% - var(--r)*1.414);
background-repeat:no-repeat;
transform:scale(0);
}
.magic i::after {
background-size:calc(var(--r)/5) calc(var(--r)/5);
transform:rotate(55deg) scale(0);
}
.magic:hover:after {
transform:scale(1);
opacity:0;
background-size:0 0;
transition:
transform 0.5s 0.5s,
opacity 0.4s 0.9s,
background-size 0.5s 0.9s;
}
.magic:hover i:after {
transform:rotate(55deg) scale(1);
opacity:0;
background-size:0 0;
transition:
transform 0.5s 0.5s,
opacity 0.4s 0.9s,
background-size 0.5s 0.9s;
}
/**/ <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.7.1/css/all.css">
<span class="magic" style="--r:80px;">
<i class="fas fa-star fa-10x"></i>
</span>
<span class="magic">
<i class="fas fa-user fa-5x"></i>
</span>
<span class="magic" style="--r:20px;">
<i class="far fa-bell fa-3x"></i>
</span>r将定义整个形状的半径,您可以根据图标的大小轻松更改。关于javascript - 如何制作 Shiny 的按钮动画?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54593203/
我正在学习如何使用Nokogiri,根据这段代码我遇到了一些问题:require'rubygems'require'mechanize'post_agent=WWW::Mechanize.newpost_page=post_agent.get('http://www.vbulletin.org/forum/showthread.php?t=230708')puts"\nabsolutepathwithtbodygivesnil"putspost_page.parser.xpath('/html/body/div/div/div/div/div/table/tbody/tr/td/div
总的来说,我对ruby还比较陌生,我正在为我正在创建的对象编写一些rspec测试用例。许多测试用例都非常基础,我只是想确保正确填充和返回值。我想知道是否有办法使用循环结构来执行此操作。不必为我要测试的每个方法都设置一个assertEquals。例如:describeitem,"TestingtheItem"doit"willhaveanullvaluetostart"doitem=Item.new#HereIcoulddotheitem.name.shouldbe_nil#thenIcoulddoitem.category.shouldbe_nilendend但我想要一些方法来使用
关闭。这个问题是opinion-based.它目前不接受答案。想要改进这个问题?更新问题,以便editingthispost可以用事实和引用来回答它.关闭4年前。Improvethisquestion我想在固定时间创建一系列低音和高音调的哔哔声。例如:在150毫秒时发出高音调的蜂鸣声在151毫秒时发出低音调的蜂鸣声200毫秒时发出低音调的蜂鸣声250毫秒的高音调蜂鸣声有没有办法在Ruby或Python中做到这一点?我真的不在乎输出编码是什么(.wav、.mp3、.ogg等等),但我确实想创建一个输出文件。
给定这段代码defcreate@upgrades=User.update_all(["role=?","upgraded"],:id=>params[:upgrade])redirect_toadmin_upgrades_path,:notice=>"Successfullyupgradeduser."end我如何在该操作中实际验证它们是否已保存或未重定向到适当的页面和消息? 最佳答案 在Rails3中,update_all不返回任何有意义的信息,除了已更新的记录数(这可能取决于您的DBMS是否返回该信息)。http://ar.ru
我在我的项目目录中完成了compasscreate.和compassinitrails。几个问题:我已将我的.sass文件放在public/stylesheets中。这是放置它们的正确位置吗?当我运行compasswatch时,它不会自动编译这些.sass文件。我必须手动指定文件:compasswatchpublic/stylesheets/myfile.sass等。如何让它自动运行?文件ie.css、print.css和screen.css已放在stylesheets/compiled。如何在编译后不让它们重新出现的情况下删除它们?我自己编译的.sass文件编译成compiled/t
我正在寻找执行以下操作的正确语法(在Perl、Shell或Ruby中):#variabletoaccessthedatalinesappendedasafileEND_OF_SCRIPT_MARKERrawdatastartshereanditcontinues. 最佳答案 Perl用__DATA__做这个:#!/usr/bin/perlusestrict;usewarnings;while(){print;}__DATA__Texttoprintgoeshere 关于ruby-如何将脚
Rackup通过Rack的默认处理程序成功运行任何Rack应用程序。例如:classRackAppdefcall(environment)['200',{'Content-Type'=>'text/html'},["Helloworld"]]endendrunRackApp.new但是当最后一行更改为使用Rack的内置CGI处理程序时,rackup给出“NoMethodErrorat/undefinedmethod`call'fornil:NilClass”:Rack::Handler::CGI.runRackApp.newRack的其他内置处理程序也提出了同样的反对意见。例如Rack
在选择我想要运行操作的频率时,唯一的选项是“每天”、“每小时”和“每10分钟”。谢谢!我想为我的Rails3.1应用程序运行调度程序。 最佳答案 这不是一个优雅的解决方案,但您可以安排它每天运行,并在实际开始工作之前检查日期是否为当月的第一天。 关于ruby-如何每月在Heroku运行一次Scheduler插件?,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/questions/8692687/
我有一个对象has_many应呈现为xml的子对象。这不是问题。我的问题是我创建了一个Hash包含此数据,就像解析器需要它一样。但是rails自动将整个文件包含在.........我需要摆脱type="array"和我该如何处理?我没有在文档中找到任何内容。 最佳答案 我遇到了同样的问题;这是我的XML:我在用这个:entries.to_xml将散列数据转换为XML,但这会将条目的数据包装到中所以我修改了:entries.to_xml(root:"Contacts")但这仍然将转换后的XML包装在“联系人”中,将我的XML代码修改为
我有一大串格式化数据(例如JSON),我想使用Psychinruby同时保留格式转储到YAML。基本上,我希望JSON使用literalstyle出现在YAML中:---json:|{"page":1,"results":["item","another"],"total_pages":0}但是,当我使用YAML.dump时,它不使用文字样式。我得到这样的东西:---json:!"{\n\"page\":1,\n\"results\":[\n\"item\",\"another\"\n],\n\"total_pages\":0\n}\n"我如何告诉Psych以想要的样式转储标量?解