screen_rotation
Copied to Clipboard
<!DOCTYPE html> <html> <head> <script src="https://unpkg.com/vue@3.2.12/dist/vue.global.js"></script> </head> <body> <div id="app"> <h3>Vue Js Open URL as Modal Popup with Overlay</h3> <button class="open-button" @click="openModal">Open Modal</button> <div class="modal-overlay" v-if="isOpen" @click.self="closeModal"> <div class="modal"> <iframe :src="url" frameborder="0"></iframe> <button class="close-button" @click="closeModal">X</button> </div> </div> </div> <script type="module"> const app = Vue.createApp({ data() { return { url: 'https://fontawesomeicons.com/fa/vue-js-open-url-as-modal-popup-with-overlay', isOpen: false }; }, methods: { openModal() { this.isOpen = true; }, closeModal() { this.isOpen = false; } } }); app.mount('#app'); </script> <style> #app { text-align: center; } .modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(0, 0, 0, 0.5); display: flex; justify-content: center; align-items: center; z-index: 9999; } .modal { background-color: #fff; padding: 20px; border-radius: 5px; position: relative; width: 100%; max-width: 800px; } .modal iframe { width: 100%; height: 400px; border: none; } .open-button { background-color: #4CAF50; color: white; padding: 10px 20px; border: none; border-radius: 4px; transition: background-color 0.3s; cursor: pointer; } .open-button:hover { background-color: #45a049; } .modal button { position: absolute; top: 10px; right: 10px; background-color: #ddd; border: none; padding: 8px 12px; border-radius: 50%; cursor: pointer; } /* Button hover effect */ .modal button:hover { background-color: #ccc; } </style> </body> </html>