screen_rotation
Copied to Clipboard
<html> <head> <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script> </head> <body> <div id="app"> <div> <h1>Vue Js Change Dynamically Background Color </h1> <p>Selected color code: {{ selectedColor }}</p> <input type="color" v-model="selectedColor"> </div> </div> <script type="module"> const app = new Vue({ el: "#app", data: { selectedColor: "#ffffff", }, watch: { selectedColor() { document.body.style.backgroundColor = this.selectedColor; }, }, }); </script> <style scoped> body { font-family: Arial, sans-serif; display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100vh; margin: 0; background-color: #f7f7f7; transition: background-color 0.5s ease-in-out; } #app { max-width: 800px; background-color: #fff; padding: 20px; border-radius: 5px; box-shadow: 0 0 10px rgba(0, 0, 0, 0.2); text-align: center; } h1 { font-size: 3rem; margin-bottom: 2rem; color: #333; } p { font-size: 1.2rem; margin-bottom: 1rem; } input[type="color"] { border: none; outline: none; width: 100px; } </style> </body> </html>