<header>
<h2 class="title">Math.floor()</h2>
<p class="description">Заокруглює число вниз до найближчого цілого.</p>
</header>
<main>
<div class="result">
<label for="numberInput">Введіть дійсне число: </label>
<input type="number" step="0.1" id="numberInput" placeholder="Наприклад, 4.7">
<button onclick="applyFloor()">Заокруглити</button>
<p id="output"></p>
</div>
</main>
body {
font-size: 16px;
line-height: 1.5;
font-family: monospace;
}
header {
background-color: #f1f1f1;
margin-bottom: 25px;
padding: 15px;
box-shadow: 0px 0px 3px 0px rgba(118, 118, 118, 1);
box-shadow: 0px 0px 3px 0px rgba(118, 118, 118, 1);
box-shadow: 0px 0px 3px 0px rgba(118, 118, 118, 1);
}
header h2.title {
padding-bottom: 15px;
border-bottom: 1px solid #999;
}
header p.description {
font-style: italic;
color: #222;
}
.result {
background-color: #f8f8f8;
padding: 15px;
box-shadow: 0px 0px 3px 0px rgba(118, 118, 118, 1);
box-shadow: 0px 0px 3px 0px rgba(118, 118, 118, 1);
box-shadow: 0px 0px 3px 0px rgba(118, 118, 118, 1);
}
button {
margin-top: 10px;
background-color: #007BFF;
border: none;
color: white;
padding: 5px 10px;
cursor: pointer;
border-radius: 4px;
}
button:hover {
background-color: #0056b3;
}
function applyFloor() {
const num = parseFloat(document.getElementById("numberInput").value);
const flooredNum = Math.floor(num);
document.getElementById("output").textContent = `Заокруглене число: ${flooredNum}`;
}
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.