<p>Вибери потрібне значення для <code>text-justify</code>:</p>
<select id="form">
<option value="none" name="value2">none</option>
<option value="auto" name="value2" selected>auto</option>
<option value="inter-word" name="value2">inter-word</option>
<option value="inter-character" name="value2">inter-character</option>
</select>
<p id="text"></p>
<hr>
<p id="block">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quia ullam vel maxime delectus fuga quod doloribus atque quisquam tenetur fugit esse nulla dignissimos quis vero sit totam aliquam suscipit nam, vitae, eius, ratione ipsam ea exercitationem. Amet, illum. Quibusdam alias neque impedit veniam blanditiis reprehenderit doloremque, ratione odio perspiciatis voluptatum.</p>
* {
box-sizing: border-box;
padding: 0;
}
body {
font-family: momospace;
font-size: 17px;
line-height: 1.5;
color: #222;
}
#form {
padding: 8px 16px;
font-size: 19px;
}
#block {
margin: 75px auto 0 auto;
background: gold;
padding: 16px;
font-size: 18px;
color: #222;
text-align: justify;
text-justify: none;
}
#text {
height: 50px;
background-color: #eee;
padding: 16px 0;
}
var block = document.getElementById('block');
var form = document.getElementById('form');
var text = document.getElementById('text');
var textArray = { 'none': 'Забороняє методи вирівнювання',
'auto': 'Браузер самостійно визначає алгоритм вирівнювання.',
'inter-word': 'Буде змінюватися інтервал між словами.',
'inter-character': 'Збільшує / зменшує пробіл між символами'};
form.onchange = function change() {
var newVal = getNewValue();
block.style.textJustify = newVal;
text.innerHTML = textArray[newVal];
}
function getNewValue() {
var result = '';
for (var i = 0; i < form.options.length; i++) {
if (form.options[i].selected == true) {
result = form.options[i].value;
}
}
return result;
}
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.