Focusing on animation and keyframes within individual div elements

I encountered an issue while trying to add hover functionality to pause my pure CSS slider. Initially, I had the pausing feature working but then I wanted to include a div displaying that it is paused. However, I realized that one element cannot trigger another element located before it. To address this, I placed the "pause display div" and the images inside a "slider_cover" div so that elements coming after could be triggered. Although I am now able to activate the "pause display div," the images in the div instantly follow the "pause display div." I'm looking for guidance on which selectors to use to trigger both divs—one to display itself and the other to set "animation-play-state: paused;"

Below is the code I am currently using:

HTML:

<div id="slider_cover"></div>
    <div id="pause" class="pause">
        <p>Paused</p>
    </div>
    <div id="slider_bg">
            <div class="picslider">         
                <img id="pic1" class="slide pause" src="./Pictures/pic1.png"></img>
                <img id="pic2" class="slide pause" src="./Pictures/pic2.png"></img>
                <img id="pic3" class="slide pause" src="./Pictures/pic3.png"></img>
            <div id="progress" class="pause"> </div>
            </div>
    </div>

CSS:

#pause p {
position: relative;
font-size: 32pt;
font-weight: bold;
margin-top: 25px;
text-align: center;
color: white;

}
#slider_cover {
position: absolute;
top: 135px;
left: 250px;
opacity: 0;
width: 750px;
height: 550px;
z-index: 12;
}
#slider_cover:hover + #pause{
max-height: 100px;
}
#slider_cover:hover img:nth-of-type(1) {
animation-play-state: paused;
-webkit-animation-play-state: paused;
-moz-animation-play-state: paused;
-o-animation-play-state: paused;
}

Please refrain from providing answers outside of CSS/HTML solutions. Thank you for your assistance!

Answer №1

Issue Resolved!

After some troubleshooting, I managed to find a solution. By adjusting the position of the "slider_cover" closing tag to encompass both desired divs, and making changes to the positioning tags within, I was able to use the "element element" selector to target my "pause" div and the ".pause" class on two separate divs.

Below are the key parts of my updated code for comparison:

HTML:

<div id="slider_cover">
<div id="pause" class="pause">
    <p>Paused</p>
</div>
<div id="slider_bg">
        <div class="picslider">         
            <img id="pic1" class="slide pause" src="./Pictures/pic1.png"></img>
            <img id="pic2" class="slide pause" src="./Pictures/pic2.png"></img>
            <img id="pic3" class="slide pause" src="./Pictures/pic3.png"></img>
        <div id="progress" class="pause"> </div>
        </div>
</div>
</div>

CSS:

#slider_cover {
position: absolute;
top: 140px;
left: 250px;
background: orange;
width: 750px;
height: 550px;
z-index: 10;
}
#slider_cover:hover > #pause{
max-height: 100px;
}
#slider_cover:hover  .pause{
animation-play-state: paused;
-webkit-animation-play-state: paused;
-moz-animation-play-state: paused;
-o-animation-play-state: paused;
}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Applicable exclusively to the parent list item

I am creating a menu with a submenu that has a varying line-height. Unfortunately, I am struggling to prevent this line-height from impacting the list items in my child (submenu). I attempted using ul.nav > li but it continues to affect the lower menu ...

Selecting JavaScript file on change as default option

Currently, I have an HTML file that prompts the user to select an XML file when the file selection is changed. Is there a way to make it so that by default, only one file is chosen? <form id='fileSelection' action=""> <center> <in ...

Is there a problem with addEventListener returning false?

What does keeping the third parameter as false in the line below signify? var el = document.getElementById("outside"); el.addEventListener("click", modifyText, false); ...

What is preventing the element from being positioned at the bottom of the container?

I have a vertical bar chart with 5 different colored sub-containers. I'm trying to position the 'chicken' sub-container at the bottom of the bar without any bottom-margin, but so far my attempts have been unsuccessful. When I try using absol ...

Enhance your design with dynamic hover effects

I need assistance with modifying the menu structure generated by Wordpress. Specifically, I want to change the background of #header-nav li ul.children li a when #header-nav li ul.children li ul.children li a:hover is active. Could someone provide guidanc ...

Tips for configuring the navigation links on the current page using Bootstrap

In my Angular application, I have set up navigation links for home, about, notifications, and logout. However, when I click on the home link, it redirects me to the login page instead of remaining on the current page. I need the functionality to stay on ...

Achieving vertical alignment of button contents in Bootstrap 4

Incorporating bootstrap 4 and material icons into my app has presented a challenge. Specifically, the issue arises when I attempt to create a button that contains both text and an icon. .button-icon { vertical-align: middle; } <button class="button ...

Display image URL data in a pop-up box when the button is clicked without dimming the background

In my quest to access the legend of a WMS layer in Openlayers 3, I have successfully obtained the legends of the layer. However, I aim to display them in a popup box with a movable and close button. Below is the content of the .html page: <label>&l ...

Solving the mystery of background color in CSS for heading/title div

I am facing an issue with the title div setup where the red background is not applied when only the leftmost div has content. Despite the 'title' div having content, the background remains white. Can anyone suggest why this might be happening? H ...

Unable to display the absolute path of the image src in WebStorm

Hey there! I recently started learning HTML5 and have been using WebStorm on my trusty Macbook Air for about two weeks now. I've encountered a problem with image sourcing that has left me puzzled. Here's my question: Why is it that images from ...

Choose dropdown menus that are pre-filled by JSON may require a manual refresh to show the content

Occasionally, I encounter an issue with a JSON file used to populate select boxes, where the items in the drop down fail to display until the page is refreshed. Despite no errors in the console or log, the loading is seamless on most occasions, leaving me ...

What causes the element with position: fixed and width 100% to exceed the viewport boundaries on iOS 8?

I'm facing an issue with an element that is fixed to the top of the page and scrolls horizontally along with the page. The CSS code for this element is quite straightforward: .thing { position: fixed; top: 0; width: 100%; height: 30px; back ...

Splitting a td tag into multiple columns dynamically with Angular

I am attempting to dynamically split the table element into separate columns. My desired layout should resemble this: https://i.sstatic.net/C81tg.png The values for name and surname are fixed at 1, but the values for subjects and grades can vary (there ma ...

Increase the space below the footer on the Facebook page to allow for an

I recently created a webpage at and noticed that it is adding extra height below the footer on my Facebook page: "" I am seeking assistance on how to remove this additional 21px height below all content in the footer. I have tried various templates but n ...

Sending a collection of text inputs from a web form and saving them in MongoDB

I have been attempting to store an array of strings from my HTML form into my database (MongoDB). Here's the HTML form for creating a new class: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"& ...

Ensure that the div stays anchored to the bottom of the page while maintaining its

Although I know this question has probably been asked and answered before, I couldn't find any useful solutions to my specific problem... I'm attempting to position a chat box div at the bottom of a page without being fixed, while still maintain ...

HTML Brickwork Picture Arrangement

I recently integrated this code into a WordPress theme and encountered an issue where the new images are displaying vertically instead of horizontally. I am seeking assistance in aligning the new images to appear on the green line instead of the red line a ...

Creating a Burger Navigation Menu with CSS and HTML using Image Overlapping

I'm encountering an issue with the new website I created for my local Church. I followed a tutorial on building a burger menu using just HTML and CSS, which you can view here. The problem arises when I attempt to place an image below the navigation m ...

Tips for loading and updating data simultaneously in VUEJS from a single input

Currently, the data is displayed in a span tag with an input for updating it Is it possible to fetch data from an API, load it into an input field, update the input with new information, and send it back? What are the best approaches for achieving this? ...

Retrieve the element located within a "block" element that is relative to the user's click event, without the

I'm pondering whether it's feasible, but here's my concept: Within my page, there are multiple identical blocks with the same classes, differing only in content. I am unable or unwilling to assign IDs because these blocks are dynamically g ...