screen_rotation
Copied to Clipboard
<!DOCTYPE html> <html> <head> <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script> <link rel='stylesheet' href='https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css'> </head> <body> <div id="app"> <div class="container"> <button class="toggle-button" @click="toggleSidebar"> <i class="fas" :class="isOpen ? 'fa-times' : 'fa-bars'"></i> </button> <div class="sidebar" :class="{ 'sidebar-open': isOpen }"> <button class="close-button" @click="toggleSidebar"> <i class="fas fa-times"></i> </button> <!-- Sidebar content --> <ul> <li>Menu Item 1</li> <li>Menu Item 2</li> <li>Menu Item 3</li> </ul> </div> <div class="main-content"> <!-- Main content --> <h1>Vue Js Open Close Sidebar | Toggle Sidebar</h1> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p> </div> </div> </div> <script> const app = Vue.createApp({ data() { return { isOpen: true, // Initially sidebar is closed }; }, methods: { toggleSidebar() { this.isOpen = !this.isOpen; // Toggle the value of isOpen }, }, }); app.mount('#app'); </script> <style> body { margin: 0; } .container { display: flex; height: 100vh; } .sidebar { width: 200px; background-color: #f8f8f8; transition: transform 0.3s ease-in-out; transform: translateX(-100%); position: relative; margin: 0; } .sidebar-open { transform: translateX(0); } .main-content { flex: 1; padding: 20px; background-color: #ffffff; max-width: 1200px; margin: 0 auto; box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.12), 0 2px 4px 0 rgba(0, 0, 0, 0.24); width: 100%; } .toggle-button, .close-button { position: absolute; top: 10px; padding: 10px; background-color: transparent; color: #4a4a4a; border: none; border-radius: 50%; cursor: pointer; font-size: 20px; transition: background-color 0.3s ease-in-out; } .toggle-button:hover, .close-button:hover { background-color: #e0e0e0; } .toggle-button:focus, .close-button:focus { outline: none; } .toggle-button i, .close-button i { font-size: inherit; } .toggle-button { left: 10px; } .close-button { right: 10px; } ul { list-style-type: none; padding: 0; margin: 0; display: flex; flex-direction: column; justify-content: center; align-items: center; margin-top: 50px; } li { padding: 10px; cursor: pointer; transition: background-color 0.3s ease-in-out; } li:hover { background-color: #f8f8f8; } li.active { background-color: #e0e0e0; } .sidebar:hover { background-color: #e0e0e0; } </style> </body> </html>