250x250
Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
Tags
- effect
- ipad
- image
- react
- jQuery
- 프론트엔드
- html5
- iOS 개발자
- 풀스택
- SWIFT
- 백엔드
- HTML
- Animation
- IOS
- xcode
- iPhone
- css3
- 자바스크립트
- 개발자
- CSS
- keyframes
- 비전공자
- 비전공 개발자
- hover
- MAC
- javascript
- 애니메이션
- php
- front-end
- button
Archives
- Today
- Total
비전공자 개발일기
Javascript - Auto Text Effect 본문
728x90
SMALL
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Auto Text Effect</title>
<link rel="stylesheet" href="style.css">
<script defer src="main.js"></script>
</head>
<body>
<h1 id="text">Starting...</h1>
<div>
<label for="speed">Speed:</label>
<input type="number" name="speed" id="speed" value="1" min="1" max="10" step="1">
</div>
</body>
</html>
@import url('https://fonts.googleapis.com/css2?family=Roboto&display=swap');
* {
box-sizing: border-box;
}
body {
background-color: #e9967a;
font-family: 'Roboto', sans-serif;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 100vh;
overflow: hidden;
margin: 0;
}
div {
position: absolute;
bottom: 20px;
background: rgba(0, 0, 0, .1);
padding: 10px 20px;
font-size: 18px;
}
input {
width: 50px;
padding: 5px;
font-size: 18px;
background-color: #e9967a;
border: none;
text-align: center;
}
input:focus {
outline: none;
}
const textEl = document.getElementById("text");
const speedEl = document.getElementById("speed");
const text = "We Love Programming!";
let index = 1;
let speed = 300 / speedEl.value;
writeText();
function writeText() {
textEl.innerText = text.slice(0, index);
index++;
if(index > text.length) {
index = 1;
}
setTimeout(writeText, speed)
}
speedEl.addEventListener("click", (e) => speed = 300 / e.target.value)
728x90
LIST
'Javascript' 카테고리의 다른 글
Javascript - Content Placeholder (0) | 2021.10.13 |
---|---|
Javascript - Button Ripple Effect (0) | 2021.10.12 |
Javascript - Animated Countdown (0) | 2021.10.10 |
Javascript - Animated Navigation (0) | 2021.10.09 |
Javascript - 3D Background Boxes (0) | 2021.10.07 |