I have a header bar and a button. I can change the color on click but I want the color change with a smooth transition or effect on click. Is it possible to do it with Vue.js?
HTML code
<html>
<head>
<title>My App</title>
</head>
<body>
<div id="app">
<div class="head" :class="{ headnew : change }"></div>
<button @click="changeIt">Change me!</button>
</div>
</body>
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js">
</script>
</html>
CSS code
.head {
background: linear-gradient(-90deg, #84CF6A, #16C0B0);
height: 60px;
margin-bottom: 15px;
}
.headnew {
background: red;
height: 60px;
margin-bottom: 15px;
}
JS code
var app = new Vue({
el: "#app",
data: {
change : false
},
methods: {
changeIt() {
this.change = true
}
}
})