溢出:隐藏的可以隐藏的偏斜dom事件?
我通过CSS的草图创建了一颗钻石,该钻石位于一个圆圈的左上角。
我设置溢出:圆圈的隐藏
。钻石如何仍然触发光标:指针
?
这是 project 的编码。
HTML
<div class='container'>
<div class='skew'></div>
</div>
CSS
.container {
position: relative;
z-index: 1;
margin-top: 150px;
margin-left: 300px;
width: 300px;
height: 300px;
border-radius: 50%;
border: 1px solid red;
overflow: hidden
}
.skew {
transform-origin: right bottom;
transform: skewX(45deg);
width: 150px;
height: 150px;
border: 1px solid blue;
cursor: pointer;
}
I created a diamond through the sketch of CSS, which is located in the upper left corner of a circle.
I set overflow: hidden
for the circle. How can the diamond still trigger cursor: pointer
?
Here is the codepen of the project.
html
<div class='container'>
<div class='skew'></div>
</div>
css
.container {
position: relative;
z-index: 1;
margin-top: 150px;
margin-left: 300px;
width: 300px;
height: 300px;
border-radius: 50%;
border: 1px solid red;
overflow: hidden
}
.skew {
transform-origin: right bottom;
transform: skewX(45deg);
width: 150px;
height: 150px;
border: 1px solid blue;
cursor: pointer;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
夹子可以解决此问题。似乎仅在铬上发生:
clip-path can fix this. It seems to happen on Chrome only:
您得到的行为是因为光标是CSS函数,当鼠标输入
.skew
的给定区域参数时,浏览器会激活浏览器。溢出:隐藏
不影响此功能。正在发生的事情是,DOM将所有东西都呈现在广场上,而边界则并不真正在乎这一点。
因此,正在发生的事情是您正在切割这片馅饼,但是您绘制的圆边缘与
div
的边缘之间仍然存在距离。您可以做的是使用:
剪辑:circle(%50)
如Temani所述,The behavior you are getting is because the cursor is a CSS function that is activated by the browser when the mouse enters the given area params of
.skew
.overflow:hidden
doesn't affect this functionality.What is happening is that the DOM renders everything out in a Square, and the border-radius doesn't really care about this.
So what is happening is that you are cutting out this piece of pie, but there is still the distance between the edge of the circle you have drawn and the edge of the
div
.What you could do is use:
clip-path: circle(%50)
as mentioned by Temani