Permalink
Branch: master
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
72 lines (63 sloc) 1.52 KB
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Scoped CSS Variables and JS</title>
<script src="https://unpkg.com/vue"></script>
</head>
<body>
<div id="app">
<h2>Update CSS Variables with <span :style="spanStyle">JS</span></h2>
<div class="controls">
<label for="spacing">Spacing:</label>
<input id="spacing" type="range" min="10" max="200" v-model="spacing">
<label for="blur">Blur:</label>
<input id="blur" type="range" min="0" max="25" v-model="blur">
<label for="base">Base Color</label>
<input id="base" type="color" v-model="base">
</div>
<img src="https://source.unsplash.com/7bwQXzbF6KE/800x500" :style="imgStyle">
</div>
<script>
var app = new Vue({
el: '#app',
data: {
spacing: 10,
blur: 10,
base: "#ffc600"
},
computed: {
spanStyle: function() {
return { color: this.base }
},
imgStyle: function() {
return {
padding: `${this.spacing}px`,
background: this.base,
filter: `blur(${this.blur}px)`
}
}
}
})
</script>
<style>
/*
misc styles, nothing to do with CSS variables
*/
body {
text-align: center;
background: #193549;
color: white;
font-family: 'helvetica neue', sans-serif;
font-weight: 100;
font-size: 50px;
}
.controls {
margin-bottom: 50px;
}
input {
width:100px;
}
</style>
</body>
</html>