screen_rotation
Copied to Clipboard
<html> <head> <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script> </head> <body> <div id="app"> <h3>Vue Image Full Screen on Click </h3> <img @click="showImage" :src="imageUrl" alt="Image" /> <div v-show="isImageVisible" class="fullscreen-image"> <span class="close-btn" @click="hideImage">×</span> <img :src="imageUrl" alt="Full screen Image" /> </div> </div> <script type="module"> const app = new Vue({ el: "#app", data() { return { isImageVisible: false, imageUrl: "https://www.sarkarinaukriexams.com/images/post/1679638793vue_js_image_fullscreen_on_click.png" }; }, methods: { showImage() { this.isImageVisible = true; document.body.style.overflow = "hidden"; // Disable scrolling }, hideImage() { this.isImageVisible = false; document.body.style.overflow = "auto"; // Enable scrolling } } }); </script> <style scoped> img { display: block; max-width: 100%; height: auto; margin: 0 auto; border-radius: 10px; box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); cursor: pointer; } .fullscreen-image { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(0, 0, 0, 0.9); display: flex; justify-content: center; align-items: center; z-index: 9999; } .fullscreen-image img { width: 100%; height: 100%; object-fit: contain; } .close-btn { position: absolute; top: 0.5rem; right: 0.5rem; font-size: 3rem; color: white; cursor: pointer; } .close-btn:hover { color: red; } </style> </body> </html>