Advertisement
Guest User

Image Viewer by uploading files

a guest
Apr 17th, 2025
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.73 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <title>Comic Reader</title>
  7. <style>
  8. body {
  9. margin: 0;
  10. padding: 0;
  11. font-family: Arial, sans-serif;
  12. background-color: #222;
  13. color: white;
  14. overflow-x: hidden;
  15. }
  16.  
  17. #header {
  18. background-color: #111;
  19. padding: 15px;
  20. text-align: center;
  21. box-shadow: 0 2px 10px rgba(0,0,0,0.5);
  22. }
  23.  
  24. #comic-container {
  25. display: flex;
  26. flex-direction: column;
  27. align-items: center;
  28. padding: 20px 0;
  29. transition: transform 0.3s ease;
  30. }
  31.  
  32. .comic-page {
  33. max-width: 100%;
  34. margin-bottom: 20px;
  35. box-shadow: 0 4px 8px rgba(0,0,0,0.3);
  36. }
  37.  
  38. #upload-container {
  39. text-align: center;
  40. padding: 20px;
  41. background-color: #333;
  42. margin-bottom: 20px;
  43. }
  44.  
  45. #file-input {
  46. display: none;
  47. }
  48.  
  49. .upload-btn {
  50. background-color: #4CAF50;
  51. color: white;
  52. padding: 10px 20px;
  53. border: none;
  54. border-radius: 4px;
  55. cursor: pointer;
  56. font-size: 16px;
  57. }
  58.  
  59. .upload-btn:hover {
  60. background-color: #45a049;
  61. }
  62.  
  63. #zoom-controls {
  64. position: fixed;
  65. bottom: 20px;
  66. right: 20px;
  67. display: flex;
  68. flex-direction: column;
  69. gap: 10px;
  70. }
  71.  
  72. .zoom-btn {
  73. width: 40px;
  74. height: 40px;
  75. border-radius: 50%;
  76. background-color: #444;
  77. color: white;
  78. border: none;
  79. font-size: 20px;
  80. cursor: pointer;
  81. display: flex;
  82. align-items: center;
  83. justify-content: center;
  84. box-shadow: 0 2px 5px rgba(0,0,0,0.3);
  85. }
  86.  
  87. .zoom-btn:hover {
  88. background-color: #555;
  89. }
  90. </style>
  91. </head>
  92. <body>
  93. <div id="header">
  94. <h1>Comic Reader</h1>
  95. </div>
  96.  
  97. <div id="upload-container">
  98. <input type="file" id="file-input" accept="image/*" multiple>
  99. <button class="upload-btn" onclick="document.getElementById('file-input').click()">Upload Comic Pages</button>
  100. </div>
  101.  
  102. <div id="comic-container"></div>
  103.  
  104. <div id="zoom-controls">
  105. <button class="zoom-btn" id="zoom-in">+</button>
  106. <button class="zoom-btn" id="zoom-out">-</button>
  107. <button class="zoom-btn" id="zoom-reset">↻</button>
  108. </div>
  109.  
  110. <script>
  111. const fileInput = document.getElementById('file-input');
  112. const comicContainer = document.getElementById('comic-container');
  113. const zoomInBtn = document.getElementById('zoom-in');
  114. const zoomOutBtn = document.getElementById('zoom-out');
  115. const zoomResetBtn = document.getElementById('zoom-reset');
  116.  
  117. let currentScale = 1;
  118.  
  119. fileInput.addEventListener('change', function(e) {
  120. const files = e.target.files;
  121.  
  122. // Clear previous content
  123. comicContainer.innerHTML = '';
  124.  
  125. if (files.length === 0) return;
  126.  
  127. for (let i = 0; i < files.length; i++) {
  128. const file = files[i];
  129.  
  130. if (!file.type.match('image.*')) continue;
  131.  
  132. const reader = new FileReader();
  133.  
  134. reader.onload = function(e) {
  135. const img = document.createElement('img');
  136. img.src = e.target.result;
  137. img.className = 'comic-page';
  138. comicContainer.appendChild(img);
  139. }
  140.  
  141. reader.readAsDataURL(file);
  142. }
  143. });
  144.  
  145. zoomInBtn.addEventListener('click', function() {
  146. currentScale *= 1.2;
  147. comicContainer.style.transform = `scale(${currentScale})`;
  148. });
  149.  
  150. zoomOutBtn.addEventListener('click', function() {
  151. currentScale /= 1.2;
  152. comicContainer.style.transform = `scale(${currentScale})`;
  153. });
  154.  
  155. zoomResetBtn.addEventListener('click', function() {
  156. currentScale = 1;
  157. comicContainer.style.transform = `scale(${currentScale})`;
  158. });
  159. </script>
  160. </body>
  161. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement