<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 20px</button> 
          
  </div>
<div id="border-width">Click on the button to change the border-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-width {
  padding: 20px;
  border-style: solid;
  border-width: medium;
}

.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-width").style.borderWidth="medium" 
  
  var x = document.getElementById("code");
  if (x.innerHTML === "border-width: medium;") {
    x.innerHTML = "border-width: medium;";
  } else {
    x.innerHTML = "border-width: medium;";
  }
}

function thin() {
  document.getElementById("border-width").style.borderWidth="thin" 
  
  var x = document.getElementById("code");
  if (x.innerHTML === "border-width: thin;") {
    x.innerHTML = "border-width: thin;";
  } else {
    x.innerHTML = "border-width: thin;";
  }
}

function thick() {
  document.getElementById("border-width").style.borderWidth="thick" 
  
  var x = document.getElementById("code");
  if (x.innerHTML === "border-width: thick;") {
    x.innerHTML = "border-width: thick;";
  } else {
    x.innerHTML = "border-width: thick;";
  }
}

function lengthPxOne() {
  document.getElementById("border-width").style.borderWidth="3px" 
  
  var x = document.getElementById("code");
  if (x.innerHTML === "border-width: 3px;") {
    x.innerHTML = "border-width: 3px;";
  } else {
    x.innerHTML = "border-width: 3px;";
  }
}

function lengthPx() {
  document.getElementById("border-width").style.borderWidth="10px 20px" 
  
  var x = document.getElementById("code");
  if (x.innerHTML === "border-width: 10px 20px;") {
    x.innerHTML = "border-width: 10px 20px;";
  } else {
    x.innerHTML = "border-width: 10px 20px;";
  }
}
Run Pen

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.