Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Clicking through layers/divs

Tags:

html

css

If I have two layers on a page, split horrizontally, with the second layer overlapping part of the first layer, is it possible to make it "click through"?

I have links in the first layer, which the second layer overlaps, which stops the links from being clickable. Is there a way to make the layer display, but be click through, while still having it's own links clickable?

edit:

Here is an example, with html and a stylesheet.

The test links become unclickable when inline with the header in Layer3, but below that they are fine. Is there a way to rectify this?

<title>Test</title>
<link rel="stylesheet" href="test.css" type="text/css">
<body>
<div id="Layer0">
<div id="Layer1" class="Layer1">
<h3 align="left">Brands</h3>
</div>
<div id="Layer2" class="Layer2"><h1>TEST</h1>
<div id="rightlayer">
<a href="test">TEST></a><p><a href="test">TEST></a><p><a href="test">TEST></a><p><a href="test">TEST></a><p><a href="test">TEST></a><p><a href="test">TEST></a><p><a href="test">TEST></a><p><a href="test">TEST></a><p><a href="test">TEST></a><p><a href="test">TEST></a><p><a href="test">TEST></a><p><a href="test">TEST></a><p><a href="test">TEST></a><p><a href="test">TEST></a><p><a href="test">TEST></a><p><a href="test">TEST></a><p><a href="test">TEST></a><p><a href="test">TEST></a><p><a href="test">TEST></a><p><a href="test">TEST></a><p><a href="test">TEST></a><p><a href="test">TEST></a><p><a href="test">TEST></a><p><a href="test">TEST></a><p><a href="test">TEST></a><p><a href="test">TEST></a><p>
</div>
</div>
<div id="Layer3" class="Layer3"><h1>Ed Hardy Auctions</h1>
</div>
</div>
</body>
</html>

And the css

#Layer0 {
    width:100%;
    height:100%;
}
body {
    margin:10px 10px 0px 10px;
    padding:0px;
    color:#999999;
    font-family:"Trebuchet MS",arial,sans-serif;
    font-size:70.5%;
}
#Layer1 {
    position:absolute;
    left:10px;
    width:200px;
    margin-top:17px;
    font-size:1.0em;
    padding-left:12px;
    padding-top:8px;
}
#Layer2 {
    background:#fff;
    margin-left:199px;
    color:#000;
}

#rightlayer {
float:right;
}
.Layer3 {
position:absolute;
top:67%;
padding:20px;
width: 100%;
}
like image 534
Joshxtothe4 Avatar asked May 29 '09 10:05

Joshxtothe4


People also ask

How do I make a div transparent in click?

You can solve this problem using the “none” value of the CSS pointer-events property. In the case of using this value, the element will not react to the pointer-events. With the help of the CSS background property put your transparent background.

How do I stop DIVS from clicking?

To disable clicking inside a div with CSS or JavaScript, we can set the pointer-events CSS property to none . Also, we can add a click event listener to the div and then call event. preventDefault inside.

Can you click on a div?

The answer is definitely yes, but you will need to write javascript code for it. We can use a click handler on the div element to make it clickable.

Why is Z Index not working?

You set z-index on a static element By default, every element has a position of static. z-index only works on positioned elements (relative, absolute, fixed, sticky) so if you set a z-index on an element with a static position, it won't work.


1 Answers

Thought I would update this as I'd been struggling with this for a few hours and think i've found a solution. Looked into using Jquery but the CSS property:

pointer-events:none;

...did exactly what I wanted.

like image 166
DrShamoon Avatar answered Nov 13 '22 13:11

DrShamoon