Я ввожу ввод с помощью приглашения и сохраняю его в "a" видеть:
<script type = "text/javascript" language = "Javascript">
var a=prompt("Please Enter Your Name ?????");
</script>
а затем я хочу, чтобы текст, хранящийся в «а», и некоторый текст, например «бла-бла-бла», был напечатан в одной строке с эффектом пишущей машинки css.
html {
min-height: 100%;
overflow: hidden;
}
body {
display: flex;
background-repeat: no-repeat;
/* background-attachment: fixed;*/
background-image: radial-gradient(black, white);
}
/* DEMO-SPECIFIC STYLES */
.typewriter h1 {
color: #fff;
font-family: monospace;
overflow: hidden; /* Ensures the content is not revealed until the animation */
border-right: .15em solid orange; /* The typwriter cursor */
white-space: nowrap; /* Keeps the content on a single line */
margin: 0 auto; /* Gives that scrolling effect as the typing happens */
letter-spacing: .15em; /* Adjust as needed */
animation:
typing 3.5s steps(40, end),
blink-caret .75s step-end infinite;
}
/* The typing effect */
@keyframes typing {
from { width: 0 }
to { width: 100% }
}
/* The typewriter cursor effect */
@keyframes blink-caret {
from, to { border-color: transparent }
50% { border-color: orange; }
}
<body>
<script type = "text/javascript" language = "Javascript">
var a = prompt("Please Enter Your Name ?????");
</script>
<div class = "typewriter">
<h1>
<script>
docment.write(a)
</script>blah blah
</h1>
</div>
</body>
Когда я запускаю его, я вижу только бла-бла-бла-анимацию, а не текст, хранящийся в «а».
Попробуйте так.
var a=prompt("Please Enter Your Name ?????");
document.getElementById("name").innerHTML = a;
html {
min-height: 100%;
overflow: hidden;
}
body
{
display: flex;
background-repeat: no-repeat;
/* background-attachment: fixed;*/
background-image: radial-gradient(black,white);
}
/* DEMO-SPECIFIC STYLES */
.typewriter h1 {
color: #fff;
font-family: monospace;
overflow: hidden; /* Ensures the content is not revealed until the animation */
border-right: .15em solid orange; /* The typwriter cursor */
white-space: nowrap; /* Keeps the content on a single line */
margin: 0 auto; /* Gives that scrolling effect as the typing happens */
letter-spacing: .15em; /* Adjust as needed */
animation:
typing 3.5s steps(40, end),
blink-caret .75s step-end infinite;
}
/* The typing effect */
@keyframes typing {
from { width: 0 }
to { width: 100% }
}
/* The typewriter cursor effect */
@keyframes blink-caret {
from, to { border-color: transparent }
50% { border-color: orange; }
}
}
<html>
<head>
<!--Google Analytics code Here -->
<title>HAPPY INDEPENDANCE DAY</title>
<link rel = "stylesheet" href = "full.css">
</head>
<body>
<div class = "typewriter">
<h1 id = "name"></h1>
</div>
</body>
</html>
В вашем коде опечатка, пожалуйста, проверьте консоль разработчика на наличие ошибок.
{
"message": "Uncaught ReferenceError: docment is not defined",
"filename": "https://stacksnippets.net/js",
"lineno": 60,
"colno": 17
}
html {
min-height: 100%;
overflow: hidden;
}
body
{
display: flex;
background-repeat: no-repeat;
/* background-attachment: fixed;*/
background-image: radial-gradient(black,white);
}
/* DEMO-SPECIFIC STYLES */
.typewriter h1 {
color: #fff;
font-family: monospace;
overflow: hidden; /* Ensures the content is not revealed until the animation */
border-right: .15em solid orange; /* The typwriter cursor */
white-space: nowrap; /* Keeps the content on a single line */
margin: 0 auto; /* Gives that scrolling effect as the typing happens */
letter-spacing: .15em; /* Adjust as needed */
animation:
typing 3.5s steps(40, end),
blink-caret .75s step-end infinite;
}
/* The typing effect */
@keyframes typing {
from { width: 0 }
to { width: 100% }
}
/* The typewriter cursor effect */
@keyframes blink-caret {
from, to { border-color: transparent }
50% { border-color: orange; }
}
}
<html>
<head>
<!--Google Analytics code Here -->
<title>HAPPY INDEPENDANCE DAY</title>
<link rel = "stylesheet" href = "full.css">
</head>
<body>
<script type = "text/javascript" language = "Javascript">
var a=prompt("Please Enter Your Name ?????");
</script>
<div class = "typewriter">
<h1><script>document.write(a) </script> blah blah</h1>
</div>
</body>
</html>