【发布时间】:2021-02-10 21:48:35
【问题描述】:
对 blazor 来说相对较新。
我一直在使用 MVC 和 webforms,但深入研究了 blazor 和 .net core...
从头到尾一直很痛苦...无论如何我的问题...
I am trying to follow this codepen, typewriter text `https://codepen.io/hckkiu/pen/KKzgEMr`
除了 blazor 之外的任何地方都非常容易实现......所以我的 CSS 和 javascript 文件加载正确,但输出永远不存在......
谁能告诉我为什么它没有加载/ blazor / c#
javascript 闪烁,但没有文本继续。
<div class='containers'>
<div class="bodys">
<p class='typewriter'>
I'm a
<span class='typewriter-text' data-text='[ "photographer. ", "designer. ", "developer. " ]'></span>
</p>
</div>
</div>
Javascript
$(document).ready(function () {
typing(0, $('.typewriter-text').data('text'));
function typing(index, text) {
var textIndex = 1;
var tmp = setInterval(function () {
if (textIndex < text[index].length + 1) {
$('.typewriter-text').text(text[index].substr(0, textIndex));
textIndex++;
} else {
setTimeout(function () { deleting(index, text) }, 2000);
clearInterval(tmp);
}
}, 150);
}
function deleting(index, text) {
var textIndex = text[index].length;
var tmp = setInterval(function () {
if (textIndex + 1 > 0) {
$('.typewriter-text').text(text[index].substr(0, textIndex));
textIndex--;
} else {
index++;
if (index == text.length) { index = 0; }
typing(index, text);
clearInterval(tmp);
}
}, 150)
}
});
CSS
bodys {
width: 100%;
height: 100%;
background-color: #3a3a3a;
}
.containers {
display: flex;
align-items: center;
width: 100%;
height: 100%;
}
.typewriter {
font-family: sans-serif;
color: black;
padding-left: 30px;
display: block;
}
.typewriter-text {
padding-right: 10px;
color: red;
border-right: solid #ffe509 7px;
text-transform: uppercase;
animation: cursor 1s ease-in-out infinite;
font-weight: bold;
}
@keyframes cursor {
from {
border-color: #ffe509;
}
to {
border-color: transparent;
}
}
@media (max-width: 767.98px) {
.typewriter {
font-size: 35px;
}
}
@media (min-width: 768px) {
.typewriter {
font-size: 60px;
}
}
【问题讨论】:
标签: javascript c# blazor