gpt4 book ai didi

html - 其他伪元素在悬停时忽略父元素 'overflow: hidden'

转载 作者:行者123 更新时间:2023-11-27 23:45:25 26 4
gpt4 key购买 nike

我有一堆元素有 50% 的边界半径来制作一个圆圈和一个旋转的元素,它们被边界半径和“溢出:隐藏”属性裁剪。

到这里就好了。

我遇到的问题是当我将鼠标悬停在忽略裁剪的任何元素上并显示其他伪元素时忽略溢出属性。我已经在 Firefox 上试过并且没问题,但在 Chrome 中我无法做任何事情来解决它。

<html>
<head>
<title></title>
<style>
.products {
margin: 0 auto;
max-width: 1280px;
text-align: center;
}
.post__product {
width: 260px;
height: 260px;
margin: 0 20px 5em;
overflow: hidden;
-webkit-border-radius: 50%;
border-radius: 50%;
position: relative;
display: inline-block;
-webkit-transition: all 250ms linear;
-moz-transition: all 250ms linear;
-o-transition: all 250ms linear;
-ms-transition: all 250ms linear;
transition: all 250ms linear;
}
.post__product:hover {
-webkit-transition: all ease 0.5s;
-moz-transition: all ease 0.5s;
-o-transition: all ease 0.5s;
-ms-transition: all ease 0.5s;
transition: all ease 0.5s;
-webkit-transform: translateY(-10px);
-moz-transform: translateY(-10px);
-o-transform: translateY(-10px);
-ms-transform: translateY(-10px);
transform: translateY(-10px);
}
.post__product .rotated-element {
z-index: 0;
width: 300px;
right: -90px;
height: 200px;
bottom: -50px;
overflow: hidden;
position: absolute;
-webkit-transform: rotate(-50deg);
-moz-transform: rotate(-50deg);
-o-transform: rotate(-50deg);
-ms-transform: rotate(-50deg);
transform: rotate(-50deg);
background-color: rgba(33,38,41,0.5);
}
.post__product .title {
right: 0;
bottom: 0;
z-index: 1;
position: absolute;
}
.post__product .title h2 {
font-weight: 300;
}
</style>
</head>

<body>
<section class="products">
<a href="#" class="post post__product">
<article>
<img src="http://www.dinamiclifestyle.com/marmol-verde.jpg" alt="" />
<!-- .title -->
<div class="rotated-element"></div>
<!-- .rotated-element -->
</article>
</a>
<!-- .post .post__product -->
<a href="#" class="post post__product">
<article>
<img src="http://www.dinamiclifestyle.com/marmol-verde.jpg" alt="" />
<!-- .title -->
<div class="rotated-element"></div>
<!-- .rotated-element -->
</article>
</a>
<!-- .post .post__product -->
<a href="#" class="post post__product">
<article>
<img src="http://www.dinamiclifestyle.com/marmol-verde.jpg" alt="" />
<!-- .title -->
<div class="rotated-element"></div>
<!-- .rotated-element -->
</article>
</a>
<!-- .post .post__product -->
<a href="#" class="post post__product">
<article>
<img src="http://www.dinamiclifestyle.com/marmol-verde.jpg" alt="" />
<!-- .title -->
<div class="rotated-element"></div>
<!-- .rotated-element -->
</article>
</a>
<!-- .post .post__product -->
<a href="#" class="post post__product">
<article>
<img src="http://www.dinamiclifestyle.com/marmol-verde.jpg" alt="" />
<!-- .title -->
<div class="rotated-element"></div>
<!-- .rotated-element -->
</article>
</a>
<!-- .post .post__product -->
<a href="#" class="post post__product">
<article>
<img src="http://www.dinamiclifestyle.com/marmol-verde.jpg" alt="" />
<!-- .title -->
<div class="rotated-element"></div>
<!-- .rotated-element -->
</article>
</a>
<!-- .post .post__product -->
</section>
<!-- .products -->
</body>

</html>

我已经用它写了一支笔:http://codepen.io/anon/pen/pJggxP

预先感谢您,如果我有任何错误,请原谅我的英语。

最佳答案

尝试添加 z-index: 2; .post__product

我认为,这个问题是相关的:Bug with transform: scale and overflow: hidden in Chrome

<html>
<head>
<title></title>
<style>
.products {
margin: 0 auto;
max-width: 1280px;
text-align: center;
}
.post__product {
width: 260px;
height: 260px;
margin: 0 20px 5em;
overflow: hidden;
-webkit-border-radius: 50%;
border-radius: 50%;
position: relative;
display: inline-block;
-webkit-transition: all 250ms linear;
-moz-transition: all 250ms linear;
-o-transition: all 250ms linear;
-ms-transition: all 250ms linear;
transition: all 250ms linear;
z-index: 2;
}
.post__product:hover {
-webkit-transition: all ease 0.5s;
-moz-transition: all ease 0.5s;
-o-transition: all ease 0.5s;
-ms-transition: all ease 0.5s;
transition: all ease 0.5s;
-webkit-transform: translateY(-10px);
-moz-transform: translateY(-10px);
-o-transform: translateY(-10px);
-ms-transform: translateY(-10px);
transform: translateY(-10px);
}
.post__product .rotated-element {
z-index: 0;
width: 300px;
right: -90px;
height: 200px;
bottom: -50px;
overflow: hidden;
position: absolute;
-webkit-transform: rotate(-50deg);
-moz-transform: rotate(-50deg);
-o-transform: rotate(-50deg);
-ms-transform: rotate(-50deg);
transform: rotate(-50deg);
background-color: rgba(33,38,41,0.5);
}
.post__product .title {
right: 0;
bottom: 0;
z-index: 1;
position: absolute;
}
.post__product .title h2 {
font-weight: 300;
}
</style>
</head>

<body>
<section class="products">
<a href="#" class="post post__product">
<article>
<img src="http://www.dinamiclifestyle.com/marmol-verde.jpg" alt="" />
<!-- .title -->
<div class="rotated-element"></div>
<!-- .rotated-element -->
</article>
</a>
<!-- .post .post__product -->
<a href="#" class="post post__product">
<article>
<img src="http://www.dinamiclifestyle.com/marmol-verde.jpg" alt="" />
<!-- .title -->
<div class="rotated-element"></div>
<!-- .rotated-element -->
</article>
</a>
<!-- .post .post__product -->
<a href="#" class="post post__product">
<article>
<img src="http://www.dinamiclifestyle.com/marmol-verde.jpg" alt="" />
<!-- .title -->
<div class="rotated-element"></div>
<!-- .rotated-element -->
</article>
</a>
<!-- .post .post__product -->
<a href="#" class="post post__product">
<article>
<img src="http://www.dinamiclifestyle.com/marmol-verde.jpg" alt="" />
<!-- .title -->
<div class="rotated-element"></div>
<!-- .rotated-element -->
</article>
</a>
<!-- .post .post__product -->
<a href="#" class="post post__product">
<article>
<img src="http://www.dinamiclifestyle.com/marmol-verde.jpg" alt="" />
<!-- .title -->
<div class="rotated-element"></div>
<!-- .rotated-element -->
</article>
</a>
<!-- .post .post__product -->
<a href="#" class="post post__product">
<article>
<img src="http://www.dinamiclifestyle.com/marmol-verde.jpg" alt="" />
<!-- .title -->
<div class="rotated-element"></div>
<!-- .rotated-element -->
</article>
</a>
<!-- .post .post__product -->
</section>
<!-- .products -->
</body>

</html>

关于html - 其他伪元素在悬停时忽略父元素 'overflow: hidden',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30125310/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com