<header>
<h2 class="title">element.style.fontWeight</h2>
<p class="description">Змінює товщину шрифту тексту елементу.</p>
</header>
<main>
<div class="result">
<p id="text">Це приклад тексту для демонстрації властивості fontWeight.</p>
<div>
<label for="fontWeightRange">Товщина шрифту: <span id="weightValue">400</span></label>
<input type="range" id="fontWeightRange" min="100" max="900" step="100" value="400">
</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);
}
.result label {
display: block;
margin: 10px 0;
}
document.getElementById('fontWeightRange').addEventListener('input', function(event) {
const weight = event.target.value;
const textElement = document.getElementById('text');
textElement.style.fontWeight = weight;
document.getElementById('weightValue').textContent = weight;
});
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.