Generation QR with HTML, CSS, JS

HTML 

<!DOCTYPE html>

<html>


<head>

    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous" />

    <script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>

    <script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.1/dist/umd/popper.min.js" integrity="sha384-9/reFTGAW83EW2RDu2S0VKaIzap3H66lZH81PoYlFhbGU+6BZp6G7niu735Sk7lN" crossorigin="anonymous"></script>

    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js" integrity="sha384-B4gt1jrGC7Jh4AgTPSdUtOBvfO8shuf57BaghqFfPlYxofvL8/KUEfYiJOMMV+rV" crossorigin="anonymous"></script>

</head>


<body>

    <div class="container d-flex flex-row justify-content-center pt-5 ">

        <div class="img">

            <img src="">

        </div>

        <div class="form  ">

            <input type="text" spellcheck="false" placeholder="Enter text or url" autocomplete="off">

            <button class="btn btn-primary">Generate QR Code</button>


        </div>

    </div>

</body>


</html>

CSS

@import url('https://fonts.googleapis.com/css2?family=Bree+Serif&family=Caveat:wght@400;700&family=Lobster&family=Monoton&family=Open+Sans:ital,wght@0,400;0,700;1,400;1,700&family=Playfair+Display+SC:ital,wght@0,400;0,700;1,700&family=Playfair+Display:ital,wght@0,400;0,700;1,700&family=Roboto:ital,wght@0,400;0,700;1,400;1,700&family=Source+Sans+Pro:ital,wght@0,400;0,700;1,700&family=Work+Sans:ital,wght@0,400;0,700;1,700&display=swap');

body {
    display: grid;
    place-items: center;
    height: 100vh;
    background-color: black;
    text-align: center;
}

input {
    padding: 8px 14px;
    border-radius: 4px;
    outline: none;
    border: 2px solid #E8CCFF;
    display: block;
    font-size: 16px;
    margin: 5px;
}

.container {
    text-align: center;
}

.img {
    margin: 10px;
    height: 150px;
}

JS

const image = document.querySelector("img"),
    input = document.querySelector("input"),
    button = document.querySelector("button"),
    api = `https://api.qrserver.com/v1/`,
    api2 = `create-qr-code/?size=150x150&data=`;

button.addEventListener("click", () => {
    image.src = `${api}${api2}${input.value}`;
});



Comments