In this video we are going to build barcode code generator using JsBaracode api source code link is description .
Subscribe : https://www.youtube.com/channel/UC9vqZpApNd4M0Pl5yR4banw
Source Code :
HTML :
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="main.css">
<title>Barcode Generator</title>
</head>
<body>
<div class="main">
<p>Barcode</p>
<input type="text" class="input" placeholder="Enter Value" maxlength="10">
<button class="submit" onclick="barcodeGen()">Generate</button>
<svg id="barcode"></svg>
</div>
<script src="barcode.js"></script>
<script src="main.js"></script>
</body>
</html>
CSS :
{
margin: 0;
padding: 0;
box-sizing: border-box;
border-radius: 5px;
}
body {
width: 100%;
height: 100vh;
display: flex;
justify-content: center;
align-items: center;
background: linear-gradient(to right top,#ff0f7b,#f89b29);
}
.main {
width: 25%;
height: auto;
padding: 25px 15px;
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
box-shadow: 0 10px 25px -10px rgba(0,0,0,0.5);
background-color: #fff;
}
.main p{
font-size: 3rem;
font-family: pacifico;
}
.main .input {
width: 90%;
padding: 10px 15px;
margin: 50px 0 0 0;
border: 2px solid #9e9e9e;
outline: none;
font-size: 1.2rem;
font-family: Josefin Sans;
}
.main .input:focus {
border: 2px solid #f89b29;
}
.main .submit {
width: 90%;
padding: 10px 0;
font-size: 1.2rem;
font-family: Josefin Sans;
border: none;
outline: none;
margin: 15px 0;
background-color: #f89b29;
color: #fff;
transition: 0.3s;
}
.main .submit:hover {
box-shadow: 0 15px 25px -10px #f89b29;
}
#barcode {
width: 90%;
margin: 25px 0;
border: 2px solid #f89b29;
}
JavaScript :
function barcodeGen() {
var data = document.querySelector('.input').value;
JsBarcode('#barcode', data , {
background : '#fff',
color : '#000',
height : 100,
displayValue : false
});
}
#js #javascript #html #css