Problem arising with CSS transitions positioned under an image

Let me illustrate the issues I am facing.

The concept involves splitting a webpage into two sections, with the left side utilizing CSS transitions and the right side displaying the actual content.

Example 1:

In this example, I have a gray image filling the entire left side, which turns completely transparent on mouse-over to reveal a clearer menu. However, the links (in this case, "Test") are supposed to have mouse-over transitions as well, but they do not work because the image is covering the text, thus preventing the mouse-over event from registering. I attempted to resolve this by exploring "pointer-events," which allows selecting text behind the image, but this prevented the transitions from triggering on the image itself since it was set as a pointer-event.

To attempt a solution, I experimented with using :hover::before, resulting in:

Example 2:

In this variation, the link and foreground transition both function correctly; however, the foreground no longer overlays the text links.

I hope this clarifies the situation,

Code Snippet 1:

<div id="left">
  <img src="graysmall.png" name="img" width="93" height="55" id="img" />
  <h2>B</h2>
  <h3><a href="../index.html">Test</a></h3>
</div>

<div id="right">
  <a href="../index.html">Scroll</a><br />
  Scroll
  <br /> (continues) 
</div>

Code Snippet 2:

<div id="left">
  <h2>B</h2>
  <h3><a href="../index.html">Home</a></h3>
</div>

<div id="right">
  <br />Scroll
  <br /> (continues)
</div>

Answer №1

Start by utilizing the initial example provided: adjust the pointer-events property of the #img element to none, followed by modifying the #img:hover selector to #left:hover>#img.

html,
body {
  height: 100%;
  margin: 0;
  font-size: 20px;
}
#left {
  text-indent: 1.5cm;
  width: 20%;
  height: 100%;
  position: fixed;
  outline: 1px solid;
  background: rgba(51, 51, 51, 0.9);
  font-family: Helvetica;
}
#right {
  width: 80%;
  height: auto;
  outline: 1px solid;
  position: absolute;
  right: 0;
  background: white;
}
#img {
  position: absolute;
  opacity: 0.8;
  width: 100%;
  height: 100%;
  pointer-events:none;
  -webkit-transition: opacity .25s ease-out;
  -moz-transition: opacity .25s ease-out;
  -o-transition: opacity .25s ease-out;
  transition: opacity .25s ease-out;
  color: #000;
}
#left:hover>#img {
  opacity: 0;
}
h2 {
  font-size: 80px;
  color: #CCC;
}
h3 {
  font-size: 20px;
  color: #CCC;
  font-weight: lighter;
}
a:link {
  text-decoration: none;
  color: #CCC;
  -webkit-transition: all 1s ease-out;
  Saf3.2+, Chrome -moz-transition: all 1s ease-out;
  FF4+ -ms-transition: all 1s ease-out;
  IE10 -o-transition: all 1s ease-out;
  Opera 10.5+ transition: all 1s ease-out;
}
a:link:hover {
  text-decoration: none;
  color: #09F;
}
a:visited {
  text-decoration: none;
  color: #CCC;
  -webkit-transition: all 1s ease-out;
  Saf3.2+, Chrome -moz-transition: all 1s ease-out;
  FF4+ -ms-transition: all 1s ease-out;
  IE10 -o-transition: all 1s ease-out;
  Opera 10.5+ transition: all 1s ease-out;
}
a:visited:hover {
  text-decoration: none;
  color: #09F;
}
a:active {
  text-decoration: none;
  color: #CCC;
  -webkit-transition: all 1s ease-out;
  Saf3.2+, Chrome -moz-transition: all 1s ease-out;
  FF4+ -ms-transition: all 1s ease-out;
  IE10 -o-transition: all 1s ease-out;
  Opera 10.5+ transition: all 1s ease-out;
}
<div id="left">
  <img src="graysmall.png" name="img" width="93" height="55" id="img" />
  <h2> B </h2>
  <h3><a href="../index.html">Test</a></h3>

</div>
<div id="right"><a href="../index.html">Scroll</a>
...
... (truncated for brevity) ...
...
<br />Scroll
  <br />Scroll
  <br />Scroll
  <br />Scroll
  <br />Scroll
  <br />Scroll
  <br />Scroll
  <br />Scroll
  <br />Scroll
  <br />Scroll
  <br />Scroll
  <br />Scroll
  <br />Scroll
  <br />Scroll
  <br />Scroll
  <br />Scroll
  <br />Scroll
  <br />Scroll
  <br />Scroll
  <br />Scroll
  <br />Scroll
  <br />Scroll
  <br />Scroll
  <br />Scroll
  <br />Scroll
  <br />Scroll
  <br />Scroll
  <br />Scroll
  <br />Scroll
  <br />Scroll
  <br />Scroll
...
... (truncated for brevity) ...
...
<br />Scroll
  <br />Scroll
  <br />Scroll
</div>

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

Using the PMT function in PHP allows for easy calculation of

I have been attempting to integrate the PMT function into my PHP code for a loan calculator. Unfortunately, the PHP code seems to be malfunctioning and I am unsure of the reason, especially since I am still at the novice level in programming. PHP(Get.php ...

The auto setting in the CSS clamp function is not functioning properly when used as the minimum, value,

I have been trying to use the css function clamp() to control the height of my div, but for some reason it is not behaving as I expected. .container{ height: clamp(200px, auto, 400px); } Interestingly, it works perfectly fine when I define the heights ...

Stop video and audio playback in an android webview

Is there a way to pause audio and video in an Android WebView without disrupting the page rendering? I have tried various methods but haven't found one that successfully pauses both the sound and the video without affecting the WebView. webView.onPau ...

What is the best way to implement form fields that have varying validation patterns based on different conditions?

Currently, my focus is on developing a form that prompts the user to choose between "USA" or "International" via radio buttons. The input field for telephone numbers should then adapt its requirements based on the selected country - either a 10-digit US nu ...

JavaScript is used to manipulate XML documents, including those that are labeled as "undefined."

I'm currently developing an interactive game using HTML5 and I have been focusing on storing various data elements, including character abilities, gear stats, and other related information. My approach involves utilizing XML for static content, while ...

It appears that the pixel sizes are different than what was originally designed

In my project, I have a header panel where the burger button is designed with a width of 32px and height of 24px. .header { display: flex; font-weight: bold; font-size: 50px; height: 100px; border: 1px solid black; position: relativ ...

Move the final column from one table to another table given a specific criterion

I have a task where I need to extract the last column from table3 and transfer it into table4. For example, consider table3: Names Process_id Total construction 1 1111 construction_1 1 0000 engineering 1 22 ...

Ensuring the positioning of input fields and buttons are in perfect alignment

I've been struggling to align two buttons next to an input field, but every time I try, I end up messing everything up. I managed to align an input field with a single button, but adding a second button is proving to be quite difficult. Here is ...

Problem with jQuery image gallery

Currently, I am in the process of creating a simple image gallery that enlarges an image when it is clicked. To achieve this functionality, I am utilizing jQuery to add and remove classes dynamically. $(".image").click(function() { $(this).addClass("b ...

Generate an adjustable grid layout (with rows and columns) to display information retrieved from an API request

I have recently started learning React JS and JavaScript. To practice, I am working on a small project where I am facing an issue with creating dynamic rows and columns. My aim is to display data in 4 columns initially and then move to a new row and column ...

Here's a way to align big text in the center while aligning small text at the bottom

How can I position two text blocks on the same line in HTML, with one text block having a larger font size and vertically aligned in the middle, while the other text block sits lower to create a cohesive design? To better illustrate what I mean, I have cre ...

What is the best way to center text vertically within an image?

How can I vertically align a blog entry title on an entry thumbnail image? The image size changes with the window size and the title varies in length for each entry. After finding a website that successfully achieved this effect, I tried replicating it us ...

Flask caches JSON files automatically

I am currently working on a visualization app using js and python. The functionality of my app is as follows: There is a textbox in the browser where I input an URL The URL is then sent to Python via Flask In Python, the URL is processed to create ...

Ways to identify the visible elements on a webpage using JavaScript

I'm working on a nextjs app , I am looking to dynamically update the active button in the navbar based on which section is currently visible on the page. The child elements of the page are structured like this: <div id="section1" > < ...

Is there a way for me to edit the HTML file in Shopify?

I'm currently navigating my way through Shopify and finding it to be a bit perplexing. Although I understand what changes need to be made and how to make them, I am struggling to locate the HTML file that requires editing. Despite clicking on Online S ...

The issue encountered with Bootstrap Carousel and the <img> tag displaying incorrect object-fit and object-position properties

Currently, I am working on a carousel design that looks like the code snippet below: <div id="myCarousel" class="carousel slide" data-ride="carousel"> <ol class="carousel-indicators"> ... </ol> <div class="carousel ...

The HTML object is experiencing difficulties with the Ajax page loader feature not functioning as

I attempted to use the code below in order to show an Ajax loader image while the page loads into an HTML object. Unfortunately, it didn't work as expected and I'm having trouble figuring out why. Everything seems to be functioning correctly exce ...

Is it possible to tailor the style output of .sass?

.bar { font-size: 16px; } Can anyone suggest a way to automatically add a newline before the closing } when converting a .sass file to a .css file? I'm specifically looking for guidance on how to implement this feature in the command sass --watch st ...

What could be causing my THREE.js Documentation Box to malfunction?

I am a newcomer trying to get the hang of THREE.js. I delved into the THREE.js Documentation and attempted to implement the code, but when I loaded my HTML page, it appeared blank. I am at a loss for what to do next. I utilized Visual Studio Code for codin ...