Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Dragonfly-30 committed Sep 18, 2024
0 parents commit dab0e53
Show file tree
Hide file tree
Showing 4 changed files with 105 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"liveServer.settings.port": 5501
}
23 changes: 23 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>QR Code Generator</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class = "main">
<h1>
QR Code Generator
</h1>
<form class = "container">
<input name = "qr-input" class="qr-input" placeholder="enter a URL or a type anything" autofocus required>
<button class="qr-button" type="submit">Generate a QR</button>
</form>
<img class="qr-img" src="" alt="">
</div>
</div>
<script src="script.js"></script>
</body>
</html>
16 changes: 16 additions & 0 deletions script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const form = document.getElementsByClassName("container")[0];
const button = form.querySelector(".qr-button");
const qrImage = document.querySelector(".qr-img")
const qrInput = form.querySelector(".qr-input");

console.log(form, button, qrImage)

form.addEventListener("submit", function(event){
event.preventDefault();
const input = qrInput.value;


const image = `https://api.qrserver.com/v1/create-qr-code/?size=150x150&data=${input}`;
qrImage.src = image;

})
63 changes: 63 additions & 0 deletions style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
*{
margin: 0;
padding: 0;
box-sizing: border-box;
}

body{
background-color: antiquewhite;
/* border: 1px solid black; */
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}

.main{
display: flex;
/* width: 50vh; */
flex-direction: column;
border: 1px solid black;
height : 70vh;
width: 80vh;
border-radius: 20px;
}

.main h1{
/* display: block; */
padding: 20px;
margin-bottom: 5px;
text-align: center;
background-color: black;
color: white;
border-radius: 0px;

}

.qr-input{
width: 90%;
margin: 20px;
padding: 15px;
border-radius: 10px;
border: none;
box-shadow: 3px 3px 3px rgba(0, 0, 0, 0.5);
}

.qr-button{
width: 90%;
margin: 20px;
margin-top: 1px;
padding: 15px;
border-radius: 10px;
border: none;
background-color: green;
color: white;
box-shadow: 3px 3px 3px rgba(0, 0, 0, 0.5);
}

.qr-img{
width: 150px;
height: 150px;
margin: 20px auto; /* This centers the image */
border: 1px solid black;
}

0 comments on commit dab0e53

Please sign in to comment.