[enter image description here][1]I am not sure how to round off a number that is given by the user. I know that I need to use javascript and html to complete this task. Despite conducting a search on Google for a solution, I was unable to find any suitable answers. I would greatly appreciate your assistance in resolving this issue.
html:<body>
<div class="container">
<h2>Round OFF Calculator<h2>
<label for="dig">INPUT THE NUMBER</label>
<input type="number" placeholder="Enter a value">
<button onclick="Math.round">Round Off</button>
</div>
css:*{
margin: 0%;
padding: 0%;
box-sizing: border-box;
}
h2{
font-family: sans-serif;
text-align: center;
font-weight: lighter;
}
button{
background-color: lightskyblue;
padding: 0.3rem;
}
input{
bottom: 100&;
}
I am clueless about the javascript, but I think I have to use Math.round to complete this.
This is my desired result in whole:
[1]: https://i.sstatic.net/LC9Ykxdr.gif
Ashmita is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
5
Just make the label
display: block
.
.container {
text-align: center;
}
label {
display: block;
margin-bottom: 1em;
}
<div class="container">
<h2>Round OFF Calculator</h2>
<label for="dig">INPUT THE NUMBER</label>
<span>Enter a value</span>
<input type="number" placeholder="Enter a value">
<button>Round Off</button>
</div>
1