diff --git a/functions.js b/functions.js index 8730a51b7b30a084bd10a23b9a96fe61a5d8cd19..fcc05e8d6eceb4acda0fd24b77bcaee64af227dd 100644 --- a/functions.js +++ b/functions.js @@ -1,15 +1,19 @@ let slideNumber = 0; -const newsImageSources = ['img/nasa_news_1.jpg', 'img/nasa_news_2.jpg', 'img/nasa_news_3.jpg']; +const newsImageSources = ['../img/nasa_news_1.jpg', '../img/nasa_news_2.jpg', '../img/nasa_news_3.jpg']; const newsTitles = ['Space Station', 'Earth', 'NASA Goddard']; const newsSubtitles = ['Expedition 48 Crew Lands Safely on Earth', 'NASA Announces Summer 2023 Hottest on Record', 'NASA\'s Webb Snaps Supersonic Outflow of Young Star']; -window.onload = onload(); +document.addEventListener("DOMContentLoaded", function() { + onload(); +}); function onload() { console.log("Page loaded"); setInterval(slideImage, 30000); + + setHoverForOverlay(); } function slideImage() { @@ -28,4 +32,24 @@ function slideImage() { slideImage.src = newsImageSource; slideTitle.textContent = newsTitle; slideSubtitle.textContent = newsSubtitle; -} \ No newline at end of file +} + +function setHoverForOverlay() { + let overlayDescription = document.querySelector('.overlay > .overlay-description'); + + overlayDescription.addEventListener("mouseover", function() { hover(true); }) + overlayDescription.addEventListener("mouseout", function() { hover(false); }) +} + +function hover(hoverActivated) { + let height = ""; + + if (hoverActivated) + height = "100%"; + else + height = "auto"; + + document.querySelectorAll(".overlay").forEach(function(element) { + element.style.height = height; + }); +} diff --git a/index.html b/index.html index 06e7c29db33e33325991e366cd9f486d91226e35..216ba8abb976e3fffaedc5d53e0570c5e85335eb 100644 --- a/index.html +++ b/index.html @@ -98,9 +98,11 @@ <img class="article-image" src="img/astronaut.jpg" alt="" /> - <div class="article-content overlay"> - <h4 class="overlay-title">Expedition 48</h4> - <h4 class="overlay-description">NASA's Record-braking Astronaut Crewmates Safely Return to Earth. Here is some additional information to the article where you can read more!</h4> + <div class="article-content"> + <div class="overlay"> + <h4 class="overlay-title">Expedition 48</h4> + <h4 class="overlay-description">NASA's Record-braking Astronaut Crewmates Safely Return to Earth. Here is some additional information to the article where you can read more!</h4> + </div> </div> </div> </div> diff --git a/styles.css b/styles.css index 65e4f219e54dcdca5109b169ebd7ec7c657e3c69..e80d5d1e1b4f05c6746da290789bfe21ba856bcb 100644 --- a/styles.css +++ b/styles.css @@ -333,11 +333,10 @@ main { font-size: 0.8rem; } - .overlay { display: flex; flex-direction: column; - justify-content: flex-end; + justify-content: flex-start; align-items: flex-start; position: absolute; bottom: 0; @@ -350,6 +349,7 @@ main { background-color: #39719e; opacity: 0.85; font-size: 0.9rem; + flex: 0 0 auto; } .overlay > .overlay-description { @@ -363,6 +363,7 @@ main { overflow: hidden; color: #111111; font-size: 0.9rem; + flex: 1 1 auto; } .overlay > .overlay-description:hover { @@ -370,6 +371,7 @@ main { overflow: visible; } + .nasa-launch { background-color: #eeeeee; }