QR Code Generator
body {
font-family: Arial, sans-serif;
background-color: #f0f0f0;
margin: 0;
padding: 0;
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
}
.container {
background-color: #fff;
border-radius: 10px;
padding: 20px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
text-align: center;
}
h1 {
color: #333;
}
.options {
margin-bottom: 20px;
}
label {
display: block;
margin-bottom: 10px;
font-weight: bold;
}
select, input {
width: 100%;
padding: 10px;
margin-bottom: 10px;
border: 1px solid #ccc;
border-radius: 5px;
font-size: 16px;
}
button {
background-color: #007BFF;
color: #fff;
border: none;
border-radius: 5px;
padding: 10px 20px;
cursor: pointer;
font-size: 16px;
}
.qr-code {
margin-top: 20px;
}
.download-button {
background-color: #28a745;
}
.download-button:hover {
background-color: #218838;
}
#download {
display: none;
}
document.getElementById("generate").addEventListener("click", function () {
const content = document.getElementById("content").value;
const data = document.getElementById("data").value;
if (!data) {
alert("Please enter data");
return;
}
const qrcode = new QRCode(document.getElementById("qrcode"), {
text: content === "url" ? data : "",
width: 128,
height: 128,
});
if (content !== "url") {
qrcode.makeCode(data);
}
document.getElementById("download").href = qrcode.toDataURL();
document.getElementById("download").style.display = "block";
});
No comments:
Post a Comment