<div class="content">
<div class="buttons">
<button class="button" onclick="medium()">medium</button>
<button class="button" onclick="thin()">thin</button>
<button class="button" onclick="thick()">thick</button>
<button class="button" onclick="lengthPxOne()">3px</button>
<button class="button" onclick="lengthPx()">10px</button>
</div>
<div id="border-right-width">Click on the button to change the border-right-width.</div>
<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;
}
#border-right-width {
padding: 20px;
border-style: solid;
border-width: medium;
border-right-color: red;
}
.buttons {
left:-40%;
position: absolute;
top:-40px;
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: absolute;
font-weight: bold;
font-size:15px;
width: 100%;
left:450px;
top:-15px;
}
function medium() {
document.getElementById("border-right-width").style.borderRightWidth="medium"
var x = document.getElementById("code");
if (x.innerHTML === "border-right-width: medium;") {
x.innerHTML = "border-right-width: medium;";
} else {
x.innerHTML = "border-right-width: medium;";
}
}
function thin() {
document.getElementById("border-right-width").style.borderRightWidth="thin"
var x = document.getElementById("code");
if (x.innerHTML === "border-right-width: thin;") {
x.innerHTML = "border-right-width: thin;";
} else {
x.innerHTML = "border-right-width: thin;";
}
}
function thick() {
document.getElementById("border-right-width").style.borderRightWidth="thick"
var x = document.getElementById("code");
if (x.innerHTML === "border-right-width: thick;") {
x.innerHTML = "border-right-width: thick;";
} else {
x.innerHTML = "border-right-width: thick;";
}
}
function lengthPxOne() {
document.getElementById("border-right-width").style.borderRightWidth="3px"
var x = document.getElementById("code");
if (x.innerHTML === "border-right-width: 3px;") {
x.innerHTML = "border-right-width: 3px;";
} else {
x.innerHTML = "border-right-width: 3px;";
}
}
function lengthPx() {
document.getElementById("border-right-width").style.borderRightWidth="10px"
var x = document.getElementById("code");
if (x.innerHTML === "border-right-width: 10px;") {
x.innerHTML = "border-right-width: 10px;";
} else {
x.innerHTML = "border-right-width: 10px;";
}
}
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.