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 |
Tags
- CSS
- effect
- html5
- SWIFT
- react
- Animation
- php
- xcode
- image
- ipad
- 애니메이션
- 비전공 개발자
- button
- HTML
- MAC
- front-end
- 프론트엔드
- hover
- jQuery
- 비전공자
- IOS
- 백엔드
- javascript
- css3
- 풀스택
- 자바스크립트
- iOS 개발자
- 개발자
- iPhone
- keyframes
Archives
- Today
- Total
비전공자 개발일기
Live Word Counter 본문
728x90
SMALL
<html lang="en">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>LIVE WORD COUNTER</title>
<!-- Google Font -->
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;700&display=swap" rel="stylesheet" />
<!-- Stylesheet -->
<link rel="stylesheet" href="style.css" />
<!-- Script -->
<script defer src="main.js"></script>
</head>
<body>
<div class="wrapper">
<div class="container">
<textarea id="input-textarea" rows="12" placeholder="Start Typing here..."></textarea>
</div>
<div class="count">
<div>
<h5 id="word-count">0</h5>
<p>Words</p>
</div>
<div>
<h5 id="charac-count">0</h5>
<p>Characters</p>
</div>
</div>
</div>
</body>
</html>
* {
padding: 0;
margin: 0;
box-sizing: border-box;
font-family: "Poppins", sans-serif;
}
body {
background-color: #8b5ceb;
}
.wrapper {
position: absolute;
width: 90vmin;
transform: translate(-50%, -50%);
top: 50%;
left: 50%;
}
.container {
background-color: #ffffff;
padding: 50px 30px 80px 30px;
border-radius: 8px;
box-shadow: 0 30px 50px rgba(30, 21, 49, 0.3);
}
textarea {
width: 100%;
border: none;
resize: none;
outline: none;
font-size: 16px;
line-height: 28px;
color: #0e101a;
}
.count {
background-color: #000000;
width: 80%;
padding: 20px;
position: relative;
transform: translate(-50%, -50%);
left: 50%;
display: flex;
justify-content: space-around;
text-align: center;
border-radius: 5px;
box-shadow: 0 20px 40px rgba(30, 21, 49, 0.4);
}
.count p {
color: #a0a0c0;
}
.count h5 {
color: #ffffff;
font-size: 32px;
}
let inputTextArea = document.getElementById("input-textarea");
let characCount = document.getElementById("charac-count");
let wordCount = document.getElementById("word-count");
inputTextArea.addEventListener("input", () => {
characCount.textContent = inputTextArea.value.length;
let txt = inputTextArea.value.trim();
wordCount.textContent = txt.split(/\s+/).filter((item) => item).length;
});
728x90
LIST
'Javascript' 카테고리의 다른 글
New Year 2023 Countdown (0) | 2022.12.02 |
---|---|
Dictionary App (0) | 2022.12.01 |
Search Highlight Text (0) | 2022.11.29 |
Blob Maker (0) | 2022.11.25 |
Flip a Coin (0) | 2022.11.24 |