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
- html5
- HTML
- MAC
- 풀스택
- front-end
- javascript
- keyframes
- 비전공 개발자
- jQuery
- IOS
- php
- 프론트엔드
- image
- iPhone
- 비전공자
- iOS 개발자
- hover
- button
- css3
- 애니메이션
- 자바스크립트
- ipad
- 개발자
- SWIFT
- effect
- CSS
- Animation
- 백엔드
- xcode
- react
Archives
- Today
- Total
비전공자 개발일기
QR code Generator 본문
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>QR CODE GENERATOR</title>
<link rel="stylesheet" href="style.css">
<script defer src="main.js"></script>
</head>
<body>
<div class="container">
<input type="text" id="text" class="input" placeholder="Enter Text">
<div>
<button type="button" id="generate">GENERATE QR</button>
<button type="button" id="clear">CLEAR</button>
</div>
<div id="qr-image">
<span class="error"></span>
<br>
<img src="" alt="QR CODE" id="img">
</div>
</div>
</body>
</html>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
background-color: #ECECEC;
font-family: Arial, Helvetica, sans-serif;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}
.container {
padding: 40px 60px;
background-color: #FFF;
display: flex;
align-items: center;
border: 5px solid rgba(190, 190, 190, 0);
box-shadow: 0 0 15px rgba(100, 100, 100, .3);
flex-direction: column;
}
.input {
padding: 12px 20px;
width: 300px;
margin-bottom: 20px;
}
button {
padding: 12px 20px;
margin-bottom: 20px;
border: 0;
background-color: #485696;
color: #FFF;
text-transform: uppercase;
font-weight: 700;
letter-spacing: 2px;
}
#qr-image {
display: none;
}
.error {
color: #F00;
font-weight: 700;
}
img {
margin-bottom: 20px;
}
let btn = document.querySelector("#generate");
let clearBtn = document.querySelector("#clear");
btn.addEventListener("click", () => {
document.querySelector("#qr-image").style.display = 'block';
let QRtext = document.querySelector("#text").value;
if(QRtext.trim().length == 0) {
document.querySelector("#qr-image .error").innerHTML = "Please enter Text";
document.querySelector("#img").style.display = 'none';
} else {
document.querySelector("#img").style.display = 'block';
document.querySelector("#qr-image .error").innerHTML = '';
document.querySelector("#img").src = `https://api.qrserver.com/v1/create-qr-code/?size=240x240&data=${QRtext}`;
}
});
clearBtn.addEventListener("click", () => {
document.querySelector("#text").value = '';
document.querySelector("#qr-image").style.display = 'none';
document.querySelector("#qr-image .error").innerHTML = '';
})
728x90
LIST
'Javascript' 카테고리의 다른 글
Tic Tae Toc (0) | 2022.07.09 |
---|---|
Chatbot (0) | 2022.07.08 |
Heart Animation Effects (0) | 2022.07.06 |
Javascript Particles (0) | 2022.07.05 |
Analog Clock (0) | 2022.07.03 |