简体   繁体   English

我还应该从 animation 的代码中添加/推断什么?

[英]What else should I add/deduce from the code of animation?

It's another question on animation in JS / CSS.这是关于 animation in JS / CSS 的另一个问题。

I'd like to ask how should I correct the code in JavaScript, in order to achieve the visual effect that, after a screen full of random characters, all the lines of random characters will disappear, with only the black background, while a new line of random characters starts generating at the top of the screen?请问JavaScript中的代码应该如何修改,才能达到满屏乱码后,乱码行全部消失,只有黑色背景,同时新的视觉效果一行随机字符开始在屏幕顶部生成? I thought it would be a solution that, after the characters in the div element fill up the whole screen, the height can be a reference to trigger the function of .removeChild() , in order to remove the appended p elements.我想这样的解决方案是,在div元素中的字符填满整个屏幕后,可以以高度为参考触发.removeChild()的function,从而移除附加的p元素。 After that, by .appendChild() it will start the generation process again at the top of the screen.之后,通过.appendChild()它将在屏幕顶部再次开始生成过程。 If not so, Is there any other ways to do it?如果不是这样,还有其他方法吗?

Thank you very much!非常感谢你!

Code:代码:

 function create_random_string(string_length) { var random_string = ''; var characters = 'ABCDEFGabcdefg'; for (var i, i = 0; i < string_length; i++) { random_string += characters.charAt(Math.floor(Math.random() * characters.length)); } return random_string; } let divElem = document.getElementById('container'); NewLine(); var MyInterval = setInterval(NewLine, 11000); function NewLine() { let text = document.createElement("p"); text.setAttribute("id", "text"); text.innerHTML = create_random_string(15); divElem.appendChild(text); } function RemoveChild() { if (divElem.clientHeight > window.innerHeight) { while (divElem.firstChild) { divElem.removeChild(divElem.firstChild) }; } }
 body { background-color: #000000; margin: 0; padding: 0; overflow: hidden; display: grid; height: 100vh; width: 100vw; } #container { place-content: center; text-align: center; line-height: 7.5vh; } #text { font-family: 'Courier New', Courier, monospace; font-size: 4vw; letter-spacing: 3vw; font-weight: bold; color: #ffffff; position: relative; } #text::before, #text::after { content: ""; position: absolute; top: 0; right: 0; bottom: 0; left: 0; } #text::before { background: #000000; animation: typewriter 10s steps(15) forwards; } #text::after { width: 0.125em; bottom: 0vh; Top: 0vh; background: #ffffff; animation: TypingBar 10s steps(15) forwards, blink 750ms steps(15) infinite; } @keyframes typewriter { 0% { left: 0; } 6.7% { left: 7vw; } 100% { left: 90vw; } } @keyframes TypingBar { 0%, 6.7% { left: 8vw; } 99.99% { left: 89.5vw; opacity: 1; } /* escape fade-in effect */ 100% { opacity: 0; } /* hide trailing cursor */ } @keyframes blink { to { background: transparent; } }
 <body> <div id="container"> <p id="text"></p> </div> </body>

 function create_random_string(string_length) { var random_string = ''; var characters = 'ABCDEFGabcdefg'; for (var i, i = 0; i < string_length; i++) { random_string += characters.charAt(Math.floor(Math.random() * characters.length)); } return random_string; } let divElem = document.getElementById('container'); NewLine(); var MyInterval = setInterval(NewLine, 11000); function NewLine() { RemoveChild(); let text = document.createElement("p"); text.setAttribute("id", "text"); text.innerHTML = create_random_string(15); divElem.appendChild(text); } function RemoveChild() { if (divElem.clientHeight > window.innerHeight) { divElem.innerHTML =""; } }
 body { background-color: #000000; margin: 0; padding: 0; overflow: hidden; display: grid; height: 100vh; width: 100vw; } #container { place-content: center; text-align: center; line-height: 7.5vh; } #text { font-family: 'Courier New', Courier, monospace; font-size: 4vw; letter-spacing: 3vw; font-weight: bold; color: #ffffff; position: relative; } #text::before, #text::after { content: ""; position: absolute; top: 0; right: 0; bottom: 0; left: 0; } #text::before { background: #000000; animation: typewriter 10s steps(15) forwards; } #text::after { width: 0.125em; bottom: 0vh; Top: 0vh; background: #ffffff; animation: TypingBar 10s steps(15) forwards, blink 750ms steps(15) infinite; } @keyframes typewriter { 0% { left: 0; } 6.7% { left: 7vw; } 100% { left: 90vw; } } @keyframes TypingBar { 0%, 6.7% { left: 8vw; } 99.99% { left: 89.5vw; opacity: 1; } /* escape fade-in effect */ 100% { opacity: 0; } /* hide trailing cursor */ } @keyframes blink { to { background: transparent; } }
 <body> <div id="container"> <p id="text"></p> </div> </body>

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

相关问题 为了从 Dynamo 和 Lex 接收正确的数据,我应该在此代码中添加/删除什么? - What should I add/remove in this code, in order to receive the correct data from Dynamo and Lex? 我应该如何管理if else条件的代码? - How should I manage my code of if else condition to something else? 如何从拨号代码中推断出国家代码? - How to deduce Country Code from Dial code? 从头开始构建附加组件应遵循的过程是什么? - What is the process that I should follow to build an add-on from scratch? 我应该从ajax调用中的服务器端代码返回什么 - what should I return from server side code in an ajax call 正则表达式:还有什么我应该使用来实现我想要的吗? - Regex: Is there something else I should be using to achieve what I want? 如何在该代码中添加幻灯片 animation - How can I add a slide animation in that code 我应该在此代码中添加些什么以使弹出窗口在10秒后出现 - What should I add to this code to make popup appear after 10 seconds 我应该添加什么代码以在节点js服务器中启用CORS? - What file should i add this code to enable CORS in node js server? 我应该在下面的代码中添加什么脚本,以便在滚动时将其添加为活动类? - What script should I be adding to below's code so that it would add class active when scrolled?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM