Certainly! You can create a simple QR code generator using HTML, JavaScript, and CSS. Here's a basic example:
**HTML:**
```html
QR Code Generator
```
**CSS (styles.css):**
```css
body {
font-family: 'Arial', sans-serif;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
}
.container {
text-align: center;
}
#qrcode {
margin-top: 20px;
}
```
**JavaScript (script.js):**
```javascript
function generateQR() {
var textInput = document.getElementById('text-input').value;
if (textInput.trim() !== '') {
var qrcode = new QRCode(document.getElementById("qrcode"), {
text: textInput,
width: 128,
height: 128
});
} else {
alert('Please enter text or URL.');
}
}
```
Make sure to download the `qrcode.min.js` library from the QRCode.js library (https://davidshimjs.github.io/qrcodejs/) and include it in the same directory as your HTML file.
This code creates a simple webpage with an input field, a button to generate the QR code, and a container to display the generated QR code.
Comments
Post a Comment