我正在创建一个选项卡界面,其中活动选项卡具有旋转变换,允许预览下一个选项卡。在预览区域单击按钮将打开下一个选项卡。
这在除IE11以外的所有浏览器中都运行良好。请参见下面的代码片段。
$(document).ready(function() {
$('button').click(function() {
alert('Button was clicked');
});
})
* {
margin: 0;
padding: 0
}
.container {
width: 400px;
height: 200px;
position: relative;
overflow: hidden;
}
.container .tab {
position: absolute;
top: 0;
left: 0;
width: 185%;
height: 140%;
transform: translateX(-50%) rotate(-25deg);
transform-origin: 50% 0;
overflow: hidden;
}
.container .tab .content {
transform: rotate(25deg);
transform-origin: 0 0;
margin-left: 50%;
position: relative;
height: 75%;
width: 55%;
}
.container .tab-1 {
z-index: 2;
}
.container .tab-1 .content {
background-color: red;
}
.container .tab-2 {
z-index: 1;
height: 200%;
}
.container .tab-2 .content {
background-color: green;
}
.container .tab-2 button {
position: absolute;
bottom: 37%;
right: 20px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="container">
<div class="tab tab-1">
<div class="content"></div>
</div>
<div class="tab tab-2">
<div class="content">
<button type="button">
Click me
</button>
</div>
</div>
</div>
我认为问题在于IE虽然可见地执行了旋转,但原始边界区域本身没有旋转,因此点击事件不会应用于背景元素。
有人有什么想法可以解决这个问题吗?jsfiddle链接在这里:https://jsfiddle.net/bmq2e2ae/1/
pointer-events: all
(而不是pointer-events: initial
)可以解决问题? - ConnorsFanpointer-events: all
。我使用你的代码片段进行了测试。我不知道我的IE配置有什么特殊设置,使它的行为与你的不同... - ConnorsFan