screen_rotation
Copied to Clipboard
<html> <head> <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script> </head> <body> <div id="app"> <h1>Click to Change Background Color</h1> <button @click="changeBackgroundColor">New Background Color</button> <p id="colorCode">{{ backgroundColor }}</p> <p>Some text...</p> </div> <script type="module"> const app = new Vue({ el: "#app", data: { backgroundColor: "", }, mounted() { this.changeBackgroundColor(); }, methods: { getRandomColor() { const letters = "0123456789ABCDEF"; let color = "#"; for (let i = 0; i < 6; i++) { color += letters[Math.floor(Math.random() * 16)]; } return color; }, changeBackgroundColor() { const newColor = this.getRandomColor(); document.body.style.background = newColor; this.backgroundColor = newColor; }, }, }); </script> <style scoped> body { font-family: Arial, sans-serif; display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100vh; margin: 0; } #app { 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: 32px; margin-bottom: 20px; } button { background-color: #007bff; color: #fff; border: none; border-radius: 3px; padding: 10px 20px; cursor: pointer; font-size: 18px; margin-bottom: 20px; transition: background-color 0.3s ease; } button:hover { background-color: #0069d9; } p { font-size: 24px; } #colorCode { font-size: 18px; margin-top: 10px; color: #333; } </style> </body> </html>