Created
November 12, 2020 10:39
-
-
Save rjitsu/6b6288bcbcf810b475d0a05f9429f629 to your computer and use it in GitHub Desktop.
Border-Radius-Previewer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="container"> | |
<h1 class="title">Border-Radius-Previewer</h1> | |
<div class="box"></div> | |
<label for="top-left">top-left-radius</label> | |
<input type="range" id="top-left" value = 0 max=200> | |
<label for="top-right">top-right-radius</label> | |
<input type="range" id="top-right" value = 0 max=200> | |
<label for="bottom-left">bottom-left-radius</label> | |
<input type="range" id="bottom-left" value = 0 max=200> | |
<label for="bottom-right">bottom-right-radius</label> | |
<input type="range" id="bottom-right" value = 0 max=200> | |
</div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const inputs = [].slice.call(document.querySelectorAll("input")); | |
// js code from wes bos | |
inputs.forEach((input) => input.addEventListener("onchange", handleUpdate)); | |
inputs.forEach((input) => input.addEventListener("mousemove", handleUpdate)); | |
function handleUpdate(e) { | |
const suffix = this.id === "base" ? "" : "px"; | |
document.documentElement.style.setProperty( | |
`--${this.id}`, | |
this.value + suffix | |
); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:ital@1&display=swap'); | |
:root{ | |
--top-left: 0px; | |
--top-right: 0px; | |
--bottom-left: 0px; | |
--bottom-right: 0px; | |
} | |
body{ | |
margin: 0; | |
} | |
*{ | |
box-sizing:border-box; | |
} | |
.container{ | |
height:100%; | |
width: 100%; | |
position: absolute; | |
display: grid; | |
padding: 4em; | |
grid-template-columns: 1fr auto; | |
font-family: 'Playfair Display', serif; | |
} | |
.box{ | |
height:20em; | |
width:20em; | |
background: cadetblue; | |
border-top-left-radius: var(--top-left); | |
border-top-right-radius: var(--top-right); | |
border-bottom-left-radius: var(--bottom-left); | |
border-bottom-right-radius: var(--bottom-right); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment