Is the hover functionality affected by the stacking order?

Check out this JSFiddle link to see the code in action: http://jsfiddle.net/qguq4/19/

Here is the HTML that works:

<div id="menu">hover me</div>
<div id="firstLayer"></div>

And here is the non-working HTML:

<div id="firstLayer"></div>
<div id="menu">hover me</div>

This is the CSS being used:

#firstLayer {
  background-image:linear-gradient(90deg,red,red);
  background-size: 100% 100%, 100% 100%;
  background-repeat: no-repeat;
  width: 100%; 
  height: 100px; 
  min-width:900px; 
  position:absolute; 
  left:0; 
  top:0;
}

#menu {
 position:absolute; 
 top: 110px; 
 left: 50%;
}

#menu:hover ~ #firstLayer {
 clip: rect(10px,800px,80px,400px);
}

The question is, why does the hover effect only work if #firstLayer comes after #menu in the HTML?

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

Looking for a way to design versatile image sliders featuring multiple buttons for various sliders? I'm interested in crafting an image slider gallery tailored to different years

I am currently working on creating an image slider gallery displaying different years. However, I'm facing challenges in making it work properly. If I select a specific year like 2017, only the corresponding images should be displayed. Can someone ass ...

Conflicting banner element positioning due to scroll bar pages interference

Is there a way to prevent elements from moving when navigating to a page with a scroll bar? I've observed that my elements shift slightly when selecting a page with a scroll bar. See an example here. I am considering forcing a scroll bar to appear on ...

The notification panel pop-up box keeps moving away from the right side

I'm currently in the process of creating a straightforward vertical notification panel, similar to the one seen on Stack Overflow. However, I've encountered an issue where the pop-up is not staying positioned correctly to the right side. It behav ...

If the condition is based on the category in category.php and single.php

I am attempting to create a conditional statement that will display specific content only if the user is in a particular category or on a single.php page associated with that category. I have experimented with these codes, but unfortunately, neither of the ...

Creating an inverted curve or border-radius for a div element is a design technique that can add

I've been tackling a project that requires me to style the border of a div in an inverted manner. To achieve this, I'm limited to using only CSS and JS without any plugins. I've searched through various online resources and similar questions ...

Using Bootstrap 4 to split lengthy text into multiple columns, similar to how it is done in Microsoft Word

Is there a way in Bootstrap4 to create MS Word-like multicolumn text flow? For example, in Word we have: https://i.sstatic.net/buCXu.png In Bootstrap4, the code below will generate a two-column grid: Example: <div class="row"> <div ...

What could be causing the discrepancy in the appearance of the Bootstrap cards between the computer and iPad screens?

Could someone please help me understand why the cards on my website appear differently on an iPad compared to a desktop? I have added <meta name="viewport" content="width=device-width"> to the beginning of the HTML document to set the width for the ...

Trouble arises when adding a .js script to the webpage

I'm feeling quite puzzled by this small piece of code, as it appears to be the simplest thing you'll come across today. Despite that, I can't help but seek guidance because I've been staring at it for what feels like an eternity and can ...

HTML and CSS: creating a loading progress bar with a buffer

Could someone assist me in adjusting the CSS and/or HTML for my loading bar? I am currently facing two issues with it. The first problem is that there seems to be an excess shadow extending outside the bar on the left and right beyond the border. This giv ...

Styling Hyperlinks with CSS

Recently, I've been playing around with links and using CSS to style them. I have successfully achieved the normal look and implemented a cool hover effect using a:hover. However, I'm facing some challenges when it comes to customizing the appear ...

What are the steps to retrieve the URL for submitting a form action?

I am facing an issue where the form action file is located in another directory, but some files need to be sent to this action file. How can I obtain the URL to send the action? -> The action needs to be directed to http://www.123456.com/ac.php Is t ...

The application of CSS styles to templates in Django is unsuccessful

The CSS theme that was previously working on the base.html is no longer functioning. I can't pinpoint what caused it to stop working. The base.html serves as the core template for all other pages. Within base.html, the following code is present: < ...

Special characters, such as Unicode emoji, may not be displayed correctly in certain browsers and appear

Attempting to incorporate emoji into a dropdown (select tag) menu in an Angular 6 project using unicode has been challenging. The browser only displays certain emojis like ♥, but others such as 😄, 😐, and 😡 appear as empty squ ...

How come certain invisible screen elements suddenly become visible when the document is printed?

When creating a play-off tournament bracket, I face the challenge of adjusting for varying numbers of participants in each round. Typically, there are 2^n participants in each tour: 16, 8, 4, 2 which can be easily accommodated in a flex column layout. Howe ...

Exploring the functionality of AngularJS routing on a webpage

Testing the routing functionality of AngularJS while creating a web page. The index.html will contain links to Home, Courses, and Students. Clicking on each link will load its respective HTML using AngularJS routing. The student information is stored in ...

What is causing this code snippet to initially produce an empty array?

Even though I was able to get the desired output by clicking "submit" a second time, the first time still gives me an empty array. function App() { const {handleSubmit, register} = useForm() const [values, setValues] = useState([]) const onSubmit ...

Unable to transfer card from the top position in the screen

Utilizing Tailwind (flowbite) for the frontend of my project, I encountered an issue where the Navbar was overlapping the Card. I attempted using mt-8 to resolve the problem, but it did not yield significant changes. What adjustments should I make to achi ...

Step-by-step guide on incorporating a unique customized ICON widget into Elementor

I am currently working on a unique widget for the Elementor plugin in Wordpress. My goal is to customize the widget ICON, which can be achieved using Elementor's get_icon function where we need to return a class with a :before pseudo-element that wil ...

Step-by-step guide on crafting a scrolling marquee with CSS or Javascript

I am in need of creating two marquees for a website project. The first marquee should showcase a repeating image while the second one should display links, both spanning the browser window at any size. It is crucial that the marquee items are displayed fro ...

Guide on excluding certain words within a paragraph using PHP

In my database, there is a paragraph that looks like this: $str ="this is a paragraph i show shortly and when i click on the view more it will show completely for that i am using the ajax and retrieve it " I display it as follows: this is a paragrap ...