<header>
<h2 class="title">element.style.lineHeight</h2>
<p class="description">Дозволяє змінювати висоту рядка тексту в елементі</p>
</header>
<main>
<div class="result">
<p id="sampleText">Це приклад тексту, який демонструє зміну висоти рядка. Використовуйте елементи управління нижче, щоб змінювати інтерліньяж цього тексту.</p>
<div>
<label for="lineHeightInput">Задайте висоту рядка:</label>
<input type="text" id="lineHeightInput" placeholder="Наприклад, 1.7 або 170%">
<button id="setLineHeightBtn">Застосувати</button>
<button id="resetLineHeightBtn">Скинути</button>
</div>
</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);
}
#sampleText {
margin-bottom: 20px;
}
label, input, button {
margin-right: 10px;
font-size: 16px;
}
document.getElementById("setLineHeightBtn").addEventListener("click", function() {
var lineHeightValue = document.getElementById("lineHeightInput").value;
document.getElementById("sampleText").style.lineHeight = lineHeightValue;
});
document.getElementById("resetLineHeightBtn").addEventListener("click", function() {
document.getElementById("sampleText").style.lineHeight = "normal";
});
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.