<h1>Change outline thickness using the slider</h1>
<input type="range" max="40" step="1" value="3">
<output class="code-container"><span class="token-selector">h1</span> { <span class="token-property">outline-width</span>: <span class="token-function">3px</span> }</output>
body {
font-family: system-ui;
text-align: center;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
min-height: 100vh;
}
h1 {
display: block;
font-size: 2em;
color: hsl(207, 90%, 54%);
padding: .8em;
outline: 3px solid hsl(207, 90%, 54%);
}
input {
width: 200px;
margin: 4rem auto 2rem;
}
output {
display: block;
}
.code-container {
width: 375px;
max-width: 100%;
overflow-x: auto;
text-align: center;
background-color: #272822;
padding: 1.5em 0;
border-radius: 3px;
color: #F8F8F2;
text-shadow: 0 1px rgba(0, 0, 0, 0.3);
font-family: Consolas, Monaco, 'Andale Mono', monospace;
}
.token-property {
color: #F92672;
}
.token-function {
color: #E6DB74;
display: inline-block;
width: 40px;
}
.token-selector {
color: #a6e22e;
}
var text = document.querySelector('h1'),
slider = document.querySelector('input');
slider.addEventListener('input', function () {
text.style.outlineWidth = this.value + 'px';
document.querySelector('.token-function').textContent = this.value + 'px';
}, false);
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.