I am facing a challenge with a div container that has a negative z-index, making it difficult to access handlers. What solutions

Currently, I'm working on a website design project for a friend. The idea is to create a visually appealing layout where the content appears between two curtains resembling a stage. A curtain also hangs across the top of the site. To navigate through the content, users can scroll up and down using div elements as slides, contained within a parent 'slides' div.

The challenge I'm facing now is related to the z-index property. By setting the container's z-index to -1, I achieved the desired effect of having the slides appear underneath the draped curtain at the top. However, this placement causes the main plane to block any clicking events that would typically occur, such as clicking on a button to navigate to other slides.

I'm seeking advice on how to tackle this issue. While I need the -1 z-index on the container for the sliding effect, it's also hindering interactive elements on the main plane. Any suggestions or solutions are welcome!

.container {
  pointer-events: none;

 a {
  text-decoration: none;
  color: #FFF;
 }

 position: relative;
 background-image: url('../images/curtains.png');
 background-repeat: no-repeat;
 background-size: cover;
 background-attachment: fixed;
 background-position: 0 -100px;

.slide {
  pointer-events: none;
  position: relative;
  overflow: hidden;
  width: 100%;
  height: 880px;
  background-color: #000;
  color: #FFF;
  text-align: center;
  z-index: -1;
  pointer-events: none;

.content {
  position: relative;
  width: 800px;
  margin: 0 auto;
  background-color: green;
}

Answer №1

To prevent the curtain from interfering with your events, consider using the CSS property pointer-events:none.

If you're dealing with older browsers, one workaround is to listen for mouse events on the curtain itself. When a mouse event is detected, hide the curtain, trigger the event for the slides, and then show the curtain again.

Check out this example to see it in action: http://jsbin.com/aBcDEFj/2/edit

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

Guide on transferring values from a Python list to an HTML progress bar

In my application, users can read news items and leave comments. These comments are then analyzed using NLP techniques to classify them as either positive or negative. My goal is to display the percentage of positive and negative comments for each news ite ...

Utilizing CSS for multiple carousels while applying unique styles to each one individually

I am currently working on modifying the code below so that it will only execute when a specific class is linked to the carousel. There are multiple carousels present on the same page. @media (min-width: 576px) and (max-width: 768px) { /* Display the 3r ...

Applying VueJS filters to refine object values

Is there a way to verify if the value of "startAt" is present in an object and return its corresponding ID? Here is the object in question: [{ "id": "1234567", "createTimestamp": "2020", "name": { "action": "", "allDay": false, "categor ...

Asking for information regarding RESTful API

Could you please assist me in identifying the most suitable technologies for integrating a RESTful API into an HTML and CSS website? The primary objective is to enable the website owner to easily log in and add news entries about their business. Addition ...

How to extract specific words or numbers from a text using cheerio JS

I am curious about how to extract all the sets of numbers that appear after "id": on every line from this URL using Cheerio in JavaScript: For example: [{ "id": 19437838336128, "product_id": 2069464547456, "title": "3", "price": "110.0 ...

Guide on verifying the presence of a validation rule on an element using JavaScript

Is there a way to add custom validation on datepicker similar to adding rules in javascript? I found this example on how to create a simple custom rule using the jQuery Validate Plugin - jQuery Validate Plugin - How to create a simple custom rule? Before ...

Why are static PropTypes used in ReactJS and do they offer any solutions or are they merely a recurring design choice?

While delving into the code base of a web application, I came across some static PropTypes that left me questioning their purpose and necessity. Here is a snippet of the code in question: static propTypes = { fetchCricketFantasyPlayers: PropTypes.fun ...

Finding the next occurrence of a word in a search using UIWebView poses a challenge

I have developed a simple UIWEBVIEW app that showcases HTML content inside a UIWEBVIEW. Within the Webview, there is a JavaScript application integrated with my Xcode project that highlights selected words when a user inputs and clicks on a "Net" button. I ...

What is the best way to prevent certain bootstrap classes from being applied across all elements?

After testing my HTML and CSS code on my local computer, it looks perfect. However, when I upload it to a server, the appearance changes. You can see it in action here: . The issue seems to be related to some bootstrap classes being activated differently ...

Is it possible to utilize the name attribute of the <input> element with JSON

Can JSON be used as the input name in HTML if properly escaped? For instance: <input type="text" name="{\"object\": \"value\", \"another object\": \"another value\"}"> ...

When using ng-click, each function is executed only a single time

After creating a function that combines two separate functions (recorder.start() and recorder.stop()), I encountered a problem where the program could only fire one of the functions at a time when they were added to one ng-click. This meant that in order f ...

AngularJS - Import and save CSV files

I have set up a nodeJS program as the server and an AngularJS web application as the client. For generating CSV files, I am utilizing the "express-csv" library (https://www.npmjs.com/package/express-csv) Below is the code for the server side: Definition ...

Master the art of customizing SweetAlert designs!

Can anyone provide guidance on how to style the AJAX response data in SweetAlert? Below is my code and a sample image. Any assistance would be greatly appreciated. Order screenshot swal({ title: "Confirm your transaction", html:true, showSpinner: ...

Utilizing the Bootstrap grid system to transform one row with two columns into two separate rows

I'm working on a grid layout that transitions like this https://i.sstatic.net/iU7mi.png When the width decreases, I want it to look like this https://i.sstatic.net/O5FAd.png This is what I have so far: .row > div { border: 1px solid black ...

Can someone please tell me the specific HTML entity that Flickr uses for the arrow icons in the action menu?

When viewing an image on FLickr () and clicking on the Actions menu button, a pop-up menu with an arrow icon appears. Interestingly, this icon is not a simple image, but rather a combination of two characters (◢◣). Has anyone been able to determine th ...

Save the function as a local variable and preserve the reference to the current object

In the prototype of my Car object, I have a function that looks like this: Car.prototype.drive = function() { this.currentSpeed = this.speed; } I find myself needing to call this drive function frequently within another function of the Car prototype. ...

Conceal certain options by utilizing multiple select criteria

I currently have a set of 3 select objects available. Colleges <select id="collegeSelect" size="8" multiple> <option value="1" >Harvard</option> <option value="2" >Stanford</option> <option value="3" >Yale& ...

Aligning the up and down vote buttons in Bootstrap for small screens

I'm currently working on implementing a voting system similar to that of Stack Overflow. However, I'm facing an issue with displaying the arrows on smaller screens. I want the arrows to be positioned next to the text, just like on StackOverflow. ...

Finding the index of a table cell's column is a simple task that can be

Is there a way to retrieve the column index of an HTML table element using jQuery? Below is my HTML code snippet: table { border:1px solid navy; width: 70%; text-align: center; } table th { text-align: center; width:100px; height:20px; } table td { widt ...

Creating engaging animations with styled components in ReactJs

I have embarked on the journey of crafting a testimonial section that bears resemblance to the testimonials displayed on the website www.runway.com. Leveraging styled-components, I've made progress in piling up the cards at the center of the screen, w ...