2016-08-01 2 views
0

고정 된 위치에서 100 % 높이와 너비로 div 아래에 링크가 있으며 Z- 인덱스 : 5 내 링크 위에이 div를 유지해야하지만 링크 작동하지 않습니다. 링크를 작동 시키되이 링크를 내 링크 위에 둘 수 있습니까?div 클릭 할 수있는 링크 아래에 링크를 만드는 방법

https://jsfiddle.net/8hu90e9x/1/

div { 
 
    background:grey; 
 
    width:100%; 
 
    height:100%; 
 
    position:fixed; 
 
    top:0; 
 
    opacity:0.5; 
 
    z-index:5 
 
} 
 

 
a { 
 
    font-size:50px; 
 
    z-index:0 
 
}
<a href="http://google.com"> My link</a> 
 

 
<div></div>

+0

을, 그러나 당신은 당신의'A'를 설정할 수 있습니다' display : block;'을 호출하고'div '로 사용합니다. – AntoineB

+1

http://stackoverflow.com/questions/3680429/click-through-a-div-to-underlying-elements –

답변

4

당신은 사업부의 CSS 규칙에 pointer-events:none;을 추가 할 수

div { 
 
    background:grey; 
 
    width:100%; 
 
    height:100%; 
 
    position:fixed; 
 
    top:0; 
 
    opacity:0.5; 
 
    z-index:5; 
 
    pointer-events:none; 
 
} 
 

 
a { 
 
    font-size:50px; 
 
    z-index:0; 
 
}
<a href="http://google.com"> My link</a> 
 

 
<div></div>

이 사업부의 목적은 배경색을 변경하는 단지의 경우 6,
0

, 그것을 삭제하고 대신이 작업을 수행하는 것이 더 쉽습니다 : 당신은 그것을 할 수 없습니다

body{ 
    background-color:lightgrey; 
} 
관련 문제