![]() |
<!DOCTYPE html>
<html>
<head>
<title>QR CODE GENERATOR</title>
</head>
<link rel="stylesheet" href="style.css">
<body>
<div class="container">
<header>
<h1>QR Code Generator</h1>
<p>type text or url to create QR code</p>
</header>
<div class="form">
<input type="text" spellcheck="false" placeholder="Enter text or url">
<button>Create QR Code</button>
</div>
<div class="qr-code">
<img src="" alt="qr-code">
</div>
</div>
</div>
<a href="https://youtu.be/qCxpC_9t2bE"><div class="link">Learn to code
<script>
const container = document.querySelector(".container"),
qrInput = container.querySelector(".form input"),
generateBtn = container.querySelector(".form button"),
qrImg = container.querySelector(".qr-code img");
let preValue;
generateBtn.addEventListener("click", () => {
let qrValue = qrInput.value.trim();
if(!qrValue || preValue === qrValue) return;
preValue = qrValue;
generateBtn.innerText = "Creating QR Code...";
qrImg.src = `https://api.qrserver.com/v1/create-qr-code/?size=200x200&data=${qrValue}`;
qrImg.addEventListener("load", () => {
container.classList.add("active");
generateBtn.innerText = "Create QR Code";
});
});
qrInput.addEventListener("keyup", () => {
if(!qrInput.value.trim()) {
container.classList.remove("active");
preValue = "";
}
});
</script>
<style>
*{
margin: 0;
padding: 0;
box-sizing: border-box;
}
body{
display: flex;
padding: 0 10px;
min-height: 100vh;
align-items: center;
background: linear-gradient(#2196f3 , #e91e63);
justify-content: center;
}
.container{
height: 265px;
max-width: 410px;
background: #ffb923;
border-radius: 7px;
padding: 20px 25px 0;
transition: height 0.2s ease;
box-shadow: 0 10px 30px rgba(0,0,0,0.1);
}
.container.active{
height: 530px;
}
header h1{
font-size: 21px;
font-weight: 500;
}
header p{
margin-top: 5px;
color: #575757;
font-size: 16px;
}
.container .form{
margin: 20px 0 25px;
}
.form :where(input, button){
width: 100%;
height: 55px;
border: none;
outline: none;
border-radius: 5px;
transition: 0.1s ease;
}
.form input{
font-size: 18px;
padding: 0 17px;
border: 1px solid #999;
}
.form input:focus{
box-shadow: 0 3px 6px rgba(0,0,0,0.13);
}
.form input::placeholder{
color: #999;
}
.form button{
color: #fff;
cursor: pointer;
margin-top: 20px;
font-size: 17px;
background: black;
}
.qr-code{
opacity: 0;
display: flex;
padding: 33px 0;
border-radius: 5px;
align-items: center;
pointer-events: none;
justify-content: center;
}
.container.active .qr-code{
opacity: 1;
pointer-events: auto;
transition: opacity 0.5s 0.05s ease;
}
.qr-code img{
width: 170px;
}
@media (max-width: 430px){
.container{
height: 255px;
padding: 16px 20px;
}
.container.active{
height: 510px;
}
header p{
color: #696969;
}
.form :where(input, button){
height: 52px;
}
.qr-code img{
width: 160px;
}
}
.link{
position:fixed ;
top:87%;
left:50%;
transform:translate(-50%,-50%);
background-color:transparent ;
width:250px;
height:70px;
text-align:center;
color:black;
font-weight:999;
font-size:4vw;
height:50px ;
font-size:20px;
padding-top:5px;
border-radius:10px;
animation:anim 1.2s linear infinite ;
}
@keyframes anim{
0%{
border-top:3px solid black;
}
25%{
border-left:3px solid orange;
}
50%{
border-bottom:3px solid green
}
75%{
border-right:3px solid yellow;
}
}
</style>