简体   繁体   English

将文本设置为屏幕右上角的动画

[英]Animate text to the top-right corner of the screen

I have a question with 4 options on the webpage.The score board is on the top-right corner of the screen 我在网页上有4个选项的问题。计分板位于屏幕的右上角

<div id="score" style="position:fixed;top:0;right:0;">
<p><b>Score:</b>1234</p>
</div>

Now when the user hits the correct answer in the first attempt I want to fade-in the text +10 on the center of the screen which then floats to the top-right corner where score is increased by 10. 现在,当用户在第一次尝试中点击正确答案时,我想淡入屏幕中心的文本+10 ,然后浮动到右上角,其中得分增加10。

I am done with the logical part which is updating the score,but the CSS part is creating headache for me.For fade-in the text "+10" (maybe I can use z-index to make it appear out of the screen) and animate it to top-right corner, I need slight help with either a snippet or a tutorial. 我完成了更新乐谱的逻辑部分,但CSS部分让我感到头痛。对于淡入文本“+10”(也许我可以使用z-index使其出现在屏幕外)并将其设置为右上角的动画,我需要一个片段或教程的轻微帮助。

I have intermediate experience in CSS and couldn't figure out the trick for the required animation.I tried on google but having problem with the keywords.Please help 我有CSS的中级经验,无法找到所需动画的技巧。我试过谷歌,但有关键字的问题。请帮助

You basically do four steps: 你基本上做了四个步骤:

  • Create the "+10" text absolutely positioned wherever you want it. 创建绝对定位在任何位置的“+10”文本。 Initially hidden. 最初是隐藏的。
  • Fade the text in - .fadeIn() 淡化文本 - .fadeIn()
  • Move the text to the corner - .animate() 将文本移动到角落 - .animate()
  • Fade the text out - .fadeOut() 淡出文本 - .fadeOut()

See the fiddle : http://jsfiddle.net/_abl/kz6WY/ 看小提琴: http//jsfiddle.net/_abl/kz6WY/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM