|
1 | 1 | <!DOCTYPE html>
|
2 | 2 | <html lang="en">
|
3 | 3 | <head>
|
4 |
| - <meta charset="UTF-8"> |
5 |
| - <meta name="viewport" content="width=device-width, initial-scale=1.0"> |
6 |
| - <title>Transparent Header Website</title> |
7 |
| - <link rel="stylesheet" type="text/css" href="style.css"> |
8 |
| - |
| 4 | + <meta charset="UTF-8"> |
| 5 | + <meta name="viewport" content="width=device-width, initial-scale=1.0"> |
| 6 | + <title>CAD Design Showcase</title> |
| 7 | + <style> |
| 8 | + body { |
| 9 | + margin: 0; |
| 10 | + padding: 0; |
| 11 | + overflow-x: hidden; |
| 12 | + font-family: Arial, sans-serif; |
| 13 | + position: relative; /* Ensure proper positioning of elements */ |
| 14 | + } |
| 15 | + nav { |
| 16 | + background-color: #333; |
| 17 | + color: #fff; |
| 18 | + padding: 10px 20px; |
| 19 | + position: fixed; |
| 20 | + top: 0; |
| 21 | + left: 0; |
| 22 | + width: 100%; |
| 23 | + z-index: 1000; |
| 24 | + } |
| 25 | + nav a { |
| 26 | + color: #fff; |
| 27 | + text-decoration: none; |
| 28 | + margin-right: 20px; |
| 29 | + } |
| 30 | + nav a:hover { |
| 31 | + color: #ccc; |
| 32 | + } |
| 33 | + .background-container { |
| 34 | + position: relative; /* Ensure overlay text positioning */ |
| 35 | + width: 100%; |
| 36 | + height: 100vh; /* Adjust as needed */ |
| 37 | + background-size: cover; |
| 38 | + background-position: center; |
| 39 | + z-index: -1; /* Ensure background is behind other content */ |
| 40 | + } |
| 41 | + .overlay-text { |
| 42 | + position: absolute; |
| 43 | + top: 20%; |
| 44 | + right: 5%; |
| 45 | + width: 200px; |
| 46 | + background-color: rgba(0, 0, 0, 0.5); |
| 47 | + color: #fff; |
| 48 | + padding: 10px; |
| 49 | + border-radius: 5px; |
| 50 | + } |
| 51 | + .footer { |
| 52 | + background-color: #333; |
| 53 | + color: #fff; |
| 54 | + padding: 10px; |
| 55 | + position: fixed; |
| 56 | + bottom: 0; |
| 57 | + left: 0; |
| 58 | + width: 100%; |
| 59 | + text-align: center; |
| 60 | + } |
| 61 | + .content { |
| 62 | + padding: 20px; |
| 63 | + margin-top: 100vh; /* Ensure content starts below the full viewport height */ |
| 64 | + background-color: rgba(255, 255, 255, 0.8); |
| 65 | + } |
| 66 | + </style> |
9 | 67 | </head>
|
10 | 68 | <body>
|
| 69 | + <nav> |
| 70 | + <a href="#home">Home</a> |
| 71 | + <a href="#about">About</a> |
| 72 | + <a href="#contact">Contact</a> |
| 73 | + <!-- Add more links as needed --> |
| 74 | + </nav> |
| 75 | + <div class="background-container" id="background-container"></div> |
| 76 | + <div class="overlay-text" id="overlay-text-1"> |
| 77 | + <p>This is overlay text 1.</p> |
| 78 | + </div> |
| 79 | + <div class="overlay-text" id="overlay-text-2"> |
| 80 | + <p>This is overlay text 2.</p> |
| 81 | + </div> |
| 82 | + <!-- Add more overlay text containers as needed --> |
| 83 | + <div class="footer"> |
| 84 | + <p>This is the footer.</p> |
| 85 | + </div> |
| 86 | + |
| 87 | + <script> |
| 88 | + const backgroundContainer = document.getElementById('background-container'); |
| 89 | + const overlayText1 = document.getElementById('overlay-text-1'); |
| 90 | + const overlayText2 = document.getElementById('overlay-text-2'); |
| 91 | + // Add more overlay text elements as needed |
| 92 | + |
| 93 | + let currentImageIndex = 1; // Initial image index |
| 94 | + const maxImages = 20; // Assuming there are 20 images |
| 95 | + |
| 96 | + // Function to preload images |
| 97 | + function preloadImages() { |
| 98 | + for (let i = 1; i <= maxImages; i++) { |
| 99 | + const imageUrl = `0000${i}`.slice(-4) + '.png'; // Format index with leading zeros |
| 100 | + const img = new Image(); |
| 101 | + img.src = imageUrl; |
| 102 | + } |
| 103 | + } |
| 104 | + |
| 105 | + // Function to update background image |
| 106 | + function updateBackgroundImage() { |
| 107 | + const imageUrl = `0000${currentImageIndex}`.slice(-4) + '.png'; // Format index with leading zeros |
| 108 | + backgroundContainer.style.backgroundImage = `url('${imageUrl}')`; |
| 109 | + } |
| 110 | + |
| 111 | + // Function to update overlay text visibility |
| 112 | + function updateOverlayText() { |
| 113 | + // Hide all overlay text elements |
| 114 | + const overlayTextElements = document.querySelectorAll('.overlay-text'); |
| 115 | + overlayTextElements.forEach(textElement => { |
| 116 | + textElement.style.display = 'none'; |
| 117 | + }); |
| 118 | + |
| 119 | + // Show overlay text for specific images |
| 120 | + if (currentImageIndex === 1) { |
| 121 | + overlayText1.style.display = 'block'; |
| 122 | + } else if (currentImageIndex === 2) { |
| 123 | + overlayText2.style.display = 'block'; |
| 124 | + } |
| 125 | + // Add more conditions to show overlay text for other images |
| 126 | + } |
| 127 | + |
| 128 | + // Function to handle mouse scroll event |
| 129 | + function handleScroll(event) { |
| 130 | + // Detect scroll direction |
| 131 | + const delta = Math.sign(event.deltaY); // -1 for scroll up, 1 for scroll down |
| 132 | + |
| 133 | + // Update current image index based on scroll direction |
| 134 | + currentImageIndex += delta; |
| 135 | + |
| 136 | + // Ensure currentImageIndex stays within the range of available images |
| 137 | + if (currentImageIndex < 1) { |
| 138 | + currentImageIndex = 1; |
| 139 | + } else if (currentImageIndex > maxImages) { |
| 140 | + currentImageIndex = maxImages; |
| 141 | + } |
| 142 | + |
| 143 | + // Update background image |
| 144 | + updateBackgroundImage(); |
| 145 | + |
| 146 | + // Update overlay text visibility |
| 147 | + updateOverlayText(); |
| 148 | + |
| 149 | + // Prevent default scroll behavior to stop the page from scrolling |
| 150 | + event.preventDefault(); |
| 151 | + } |
| 152 | + |
| 153 | + // Add scroll event listener to the document |
| 154 | + document.addEventListener('wheel', handleScroll, { passive: false }); |
11 | 155 |
|
12 |
| -<header> |
13 |
| - <nav> |
14 |
| - <a href="#">Home</a> |
15 |
| - <a href="#">About</a> |
16 |
| - <a href="#">Services</a> |
17 |
| - <a href="#">Contact</a> |
18 |
| - </nav> |
19 |
| -</header> |
20 |
| - |
21 |
| -<div class="container"> |
22 |
| - <h1>Welcome to Our Website</h1> |
23 |
| - <p>This is a sample homepage with a transparent header.</p> |
24 |
| - <img src="https://via.placeholder.com/800x400" alt="Sample Image"> |
25 |
| -</div> |
| 156 | + // Preload images when the page loads |
| 157 | + window.addEventListener('load', preloadImages); |
26 | 158 |
|
| 159 | + // Initially set the background image and overlay text |
| 160 | + updateBackgroundImage(); |
| 161 | + updateOverlayText(); |
| 162 | + </script> |
27 | 163 | </body>
|
28 | 164 | </html>
|
0 commit comments