Images positioned absolutely do not function with links

It seems that the link on line 44 only works when I remove 'position absolute' from my images. I have tested this issue on various browsers including opera, firefox, IE, safari and chrome.

I attempted to change the z-index of my link but did not see any difference in the result.

If you would like to see this problem for yourself, you can download the images and code from this link:

I have also included the code directly on this page :

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Document sans nom</title>

<style>

section>img:first-child
{
    position:absolute;
    left:0px; top:0;
}

section>img:nth-child(2)
{
    position:absolute;
    right:0px; top:0;
}

article
{
    padding:50px;
}

a
{
    z-index:10;
}

</style>

</head>

<body>

        <section>

            <img alt="article_end" src="main_top_left.png"/>
            <img alt="article_end" src="main_top_right.png"/>


            <article>
              <a href="www.google.fr">LINK</a> 
            </article>

        </section>   

</body>
</html>

Answer №1

The z-index property will only have an effect on elements that are positioned with either position: absolute or position: relative. To ensure your link appears "on top of" your images, you should apply a position of relative to it.

Here is a live example demonstrating this concept:

You can also refer to the following resource for more information on the topic: Understanding z-index in CSS

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

CSS login validator immobilized

In my Visual Studio project, I am facing an issue with applying CSS to two requiredfield validators. I have tried using the following code: #vdtrUserLogin { top:65px; left:750; position:absolute} #vdtrPasswordLogin0 { top:65px; left:900; position:absolute ...

Would you like to store modified CSS properties in a cookie?

Currently, I am facing a challenge while working on an ASPX page where CSS is used to define DIV properties. Although these properties can be altered on the page, they do not reflect when attempting to print them. Is there a method to modify CSS properties ...

Exploring the Impact of 2 HostBindings on Class Generation from Inputs in Angular 4

I'm struggling with the code in my component, which looks like this: @Component({ selector: "home", templateUrl: "./home.html" }) export class Home { constructor() {} @HostBinding("class") @Input() public type: string = "alert" @HostBindi ...

Struggling to remove background image in WP CSS causing overlapping menus in submenu

I recently followed a tutorial on "Overlapping Tabs" for a WordPress project and found it to be quite helpful and functional. The tutorial can be viewed at After implementing the tabs from the tutorial, I decided to add dropdown submenus to enhance the fu ...

Watir /Cucumber Element not found: dd-field div.dd-arrow-box (CSS Selector)

Chief complaint: The element cannot be located using CSS Selector Custom Css path: html.ng-scope body.ng-scope div.snap-content div.content-container div.ng-scope div.content-box div div.cb-landing-module div.deposit-acct-box div.dropdown div.dd-field ...

Why is the Google Map missing from the Bootstrap modal dialog?

I have multiple links on my website, each describing a different location with unique map data. I would like to display a modal bootstrap dialog with an embedded Google map when a user clicks on any of the links - ensuring that the location shown correspon ...

What is the best way to determine the number of matching characters between two strings?

Currently, I am working on developing a function to determine the number of identical characters in two strings that are provided as input. let [string1, string2] = target.split(",").map(p => p.trim()); let [length, char1, char2] = ""; let total ...

Why isn't my CSS button changing color on hover?

div ul li a.button:hover { text-color:#FF0000; background: #0040FF; } I have been attempting to create buttons that change color and text when hovered over. Despite trying different methods, the changes do not seem to be taking effect. Below is the co ...

Overlay causing z-index conflict

I am struggling to create an overlay effect that is not displaying correctly. .overlay { position: absolute; background-color: rgba(0, 0, 0, 0.6); z-index: -1; width: 100%; height: 100%; } .center-div { position: absolute; top: 50%; left ...

Display a smaller image preview in the product photo gallery

Hey there! I'm currently working on a website and looking to showcase my product in a similar way as shown here: I would like my main image to be displayed with all the other variants of the product image underneath, along with the same visual effect ...

Consistent height for h2 containers across all CSS grid columns

Is there a way to ensure all h2 containers have the same height, both with JavaScript and without it? The h2 titles are dynamic and can vary in length, but I want to maximize the space for all containers. img { max-width: 100%; height: auto; } .gri ...

What is preventing me from using jQuery to dynamically insert HTML onto the page?

Below is the HTML code for a Bootstrap Modal dialog box: <div class="modal fade" id="rebateModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"> <div class="modal-dialog"> <div class="modal-content"> ...

Different ways to generate DOM element using jQuery

When it comes to creating a new DOM element from JavaScript or jQuery code, there are numerous methods to consider. Some examples include: $('<div>').prop('id','someid').addClass('someclass'); $('<div& ...

Having trouble with the placement of my footer div - seeking a solution

I've been trying to center my footer, but it keeps aligning to the left. Here's a screenshot for reference Below is the code I'm working with (core.blade.php): <div class="footer"> <div class="row align-self-end& ...

CSS Issue with Background Image not Fully Covering Viewport Width

Why isn't the CSS background covering the entire viewport width when using media query @media (max-width: 62.5em)? https://i.sstatic.net/yvGWd.png I've attempted to use background-size: cover, background-position: top left, and background-repea ...

Adding a simulated bottom border to a rotated container

Currently, I am utilizing the CSS3 rotate value to create an arrowhead effect for modal boxes. However, I now require a full arrowhead design with a bottom border. As this involves rotating a div at a 45° angle, adding another border to either side will n ...

class name not functioning at the event

I am currently utilizing the fullcalendar tool from arshaw.com/fullcalendar to exhibit events on a calendar within our corporate intranet. I initially had the className attribute functioning properly, but after making some modifications to the code, I am n ...

Controlling the Flow of Events in JavaScript Documents

Explore the integration of two interconnected Javascript files and delve into managing event propagation between them effectively. 1st js file var red = [0, 100, 63]; var orange = [40, 100, 60]; var green = [75, 100, 40]; var blue = [196, 77, 55]; var ...

The navbar at the top of the page remains in place and obscures

I am facing an issue where my fixed navbar code breaks up into individual boxes for the links when I try to scroll, covering the page title. How can I resolve this? My code is too long to post directly here, so it's available on pastebin at the follow ...

Converting HTML/Javascript codes for Android Application use in Eclipse: A Step-by-Step Guide

How can I implement this in Java? Here is the HTML: <head> <title>Google Maps JavaScript API v3 Example: Geocoding Simple</title> <link href="http://code.google.com/apis/maps/documentation/javascript/examples/default.css" rel="styles ...