<header>
<h2 class="title">element.style.borderStyle</h2>
<p class="description">Змінює стиль обведення елемента</p>
</header>
<main>
<div class="result">
<!-- Елемент, для якого будемо змінювати обведення -->
<div id="styledElement" class="styled-element">Цей елемент має змінюване обведення</div>
<!-- Перемикачі для вибору стилю обведення -->
<form id="borderStyleForm">
<label>
<input type="radio" name="borderStyle" value="solid" checked> Solid
</label>
<label>
<input type="radio" name="borderStyle" value="dotted"> Dotted
</label>
<label>
<input type="radio" name="borderStyle" value="dashed"> Dashed
</label>
<label>
<input type="radio" name="borderStyle" value="double"> Double
</label>
<label>
<input type="radio" name="borderStyle" value="groove"> Groove
</label>
</form>
</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);
}
.styled-element {
padding: 20px;
margin-bottom: 20px;
border: 2px solid black;
}
document.getElementById('borderStyleForm').addEventListener('change', function(event) {
const selectedStyle = document.querySelector('input[name="borderStyle"]:checked').value;
const element = document.getElementById('styledElement');
element.style.borderStyle = selectedStyle;
});
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.