-
Notifications
You must be signed in to change notification settings - Fork 638
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16 from Hetu1107/master
35 - Decimal to Binar Project added#4
- Loading branch information
Showing
7 changed files
with
186 additions
and
0 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<link | ||
rel="shortcut icon" | ||
href="assests/Binary icon.png" | ||
type="image/x-icon" | ||
/> | ||
<link rel="stylesheet" href="style.css" /> | ||
<title>Decimal To Binary</title> | ||
</head> | ||
<body> | ||
<div class="container"> | ||
<h2>Decimal To Binary</h2> | ||
<div class="input"> | ||
<h4>Decimal</h4> | ||
<input type="number" id="input_number" /> | ||
</div> | ||
<button id="Binary_convert" onclick="calculate()">Convert</button> | ||
<div class="input"> | ||
<h4>Binary</h4> | ||
<input type="number" id="output_number" /> | ||
</div> | ||
</div> | ||
<footer> | ||
<p> | ||
< / > with ❤️ by | ||
<a href="https://swapnilsparsh.github.io/">Swapnil Srivastava</a> | ||
<br /> | ||
<a | ||
href="https://github.com/swapnilsparsh/30DaysOfJavaScript" | ||
target="_blank" | ||
>#30DaysOfJavaScript</a | ||
> | ||
</p> | ||
</footer> | ||
|
||
<script src="script.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
let input = document.getElementById('input_number'); | ||
let output = document.getElementById('output_number'); | ||
|
||
|
||
function calculate(){ | ||
let number = input.value; | ||
if(isNaN(number) || number==""){ | ||
alert("given value is not a number"); | ||
output.value = ""; | ||
} | ||
if(number==0){ | ||
output.value = 0; | ||
} | ||
else{ | ||
let response = ""; | ||
while(number>0){ | ||
response=number%2 + response; | ||
number=Math.floor(number/2); | ||
} | ||
output.value = response; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
* { | ||
padding: 0; | ||
margin: 0; | ||
box-sizing: border-box; | ||
font-family: "sans"; | ||
} | ||
|
||
@font-face { | ||
font-family: "sans"; | ||
src: url(font/sans.ttf); | ||
} | ||
|
||
body { | ||
background-color: #19172e; | ||
} | ||
|
||
.container { | ||
width: 40%; | ||
height: 500px; | ||
margin: 3rem auto; | ||
text-align: center; | ||
background: rgba(255, 255, 255, 0.05); | ||
box-shadow: 0 15px 25px rgba(0, 0, 0, 0.1); | ||
border-radius: 20px; | ||
backdrop-filter: blur(20px); | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: center; | ||
align-items: center; | ||
position: relative | ||
} | ||
.container h2{ | ||
position: absolute; | ||
top: 10px; | ||
color: white; | ||
} | ||
.container .input{ | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: flex-start; | ||
width: 100%; | ||
/* align-items: center; */ | ||
height: fit-content; | ||
position: relative; | ||
} | ||
.container .input h4{ | ||
text-align: left; | ||
color: rgba(255, 255, 255, 0.795); | ||
font-size: 16px; | ||
margin-bottom: 5px; | ||
font-weight: 400; | ||
margin-left: 3%; | ||
} | ||
.container .input input{ | ||
width: 90%; | ||
height: 40px; | ||
outline: none; | ||
border: none; | ||
font-size: 20px; | ||
padding: 0 2%; | ||
margin-left: 3%; | ||
border-radius: 3px; | ||
} | ||
.container button{ | ||
width: 100px; | ||
height: 35px; | ||
outline: none; | ||
border: none; | ||
margin: 20px 0; | ||
font-size: 18px; | ||
border-radius: 3px; | ||
background-color: white; | ||
cursor: pointer; | ||
transition: all 300ms ease; | ||
} | ||
.container button:hover{ | ||
background-color: rgb(253, 207, 78); | ||
} | ||
.container button:active{ | ||
background-color: #1e8e3e; | ||
} | ||
|
||
|
||
|
||
|
||
/* remove up and down arrow in input number */ | ||
input[type="number"]::-webkit-inner-spin-button, | ||
input[type="number"]::-webkit-outer-spin-button { | ||
-webkit-appearance: none; | ||
margin: 0; | ||
} | ||
|
||
footer { | ||
color: white; | ||
position: absolute; | ||
text-align: center; | ||
font-size: 1rem; | ||
left: 0; | ||
right: 0; | ||
bottom: 0; | ||
padding: 5px; | ||
line-height: 3vh; | ||
} | ||
|
||
footer a:visited { | ||
color: inherit; | ||
} | ||
|
||
|
||
@media (max-width: 800px){ | ||
.container{ | ||
width: 80%; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters