<div class="content">
<div class="buttons">
<button class="button" onclick="normal()">normal</button>
<button class="button" onclick="one()">-5px</button>
<button class="button" onclick="two()">-10px</button>
<button class="button" onclick="three()">15px</button>
<button class="button" onclick="four()">35px</button>
</div>
<div id="text" style="font-size: 35px;">CSS
word-spacing Property</div>
</br>
<div class="col"><h2>CSS Code:</h2><p id="code">CSS code</p>
</div>
</div>
body {
height: 100vh;
display: flex;
align-items: center;
justify-content: center;
}
.content {
position: relative;
}
.buttons {
position: relative;
left:-200px;
z-index:1;
}
button {
background-color: #333;
color: white;
border: none;
display: block;
padding:5px;
width: 100px;
margin:5px;
transition: .2s;
font-weight: bold;
}
button:hover {
background-color: white;
color: #333;
}
.col {
position: relative;
font-weight: bold;
font-size:15px;
width: 150px;
left:-200px;
top:0;
}
#text {
font-family: arial;
position: absolute;
top:0;
left:-45%;
width:600px;
}
function normal() {
document.getElementById("text").style.wordSpacing="normal"
var x = document.getElementById("code");
if (x.innerHTML === "word-spacing: normal;") {
x.innerHTML = "word-spacing: normal;";
} else {
x.innerHTML = "word-spacing: normal;";
}
}
function one() {
document.getElementById("text").style.wordSpacing="-5px"
var x = document.getElementById("code");
if (x.innerHTML === "word-spacing: -5px;") {
x.innerHTML = "word-spacing: -5px;";
} else {
x.innerHTML = "word-spacing: -5px;";
}
}
function two() {
document.getElementById("text").style.wordSpacing="-10px"
var x = document.getElementById("code");
if (x.innerHTML === "word-spacing: -10px;") {
x.innerHTML = "word-spacing: -10px;";
} else {
x.innerHTML = "word-spacing: -10px;";
}
}
function three() {
document.getElementById("text").style.wordSpacing="15px"
var x = document.getElementById("code");
if (x.innerHTML === "word-spacing: 15px;") {
x.innerHTML = "letter-spacing: 15px;";
} else {
x.innerHTML = "word-spacing: 15px;";
}
}
function four() {
document.getElementById("text").style.wordSpacing="35px"
var x = document.getElementById("code");
if (x.innerHTML === "word-spacing: 35px;") {
x.innerHTML = "letter-spacing: 35px;";
} else {
x.innerHTML = "word-spacing: 35px;";
}
}
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.