gpt4 book ai didi

html - 使用 2D 变换时的 1px 白线

转载 作者:行者123 更新时间:2023-11-28 12:11:29 29 4
gpt4 key购买 nike

我有一张带有背景图片的图片,将鼠标悬停在它上面会使用 CSS 2D 变换进行缩放和旋转。一切正常,除了 1px 的白色间隙线,看起来很糟糕。这不仅发生在 Chrome 中,而且几乎所有浏览器都会发生。我尝试了以下方法,但没有成功:

  • -webkit-backface-visibility: hidden 添加到图像 div 和/或它的包装
  • -webkit-transform: translateZ(0) scale(1.0, 1.0) 添加到图像 div 和/或其包装器
  • 尝试不同的显示
  • 尝试不同的position

我认为这个问题只有在使用 overflow: hidden 时才会出现。

HTML:

<a href="#" class="article col-xs-4">
<div class="article-overlay"></div>

<div class="article-content">
<h2>Learn the skills to land your dream job</h2>
<h6>Education / Academy</h6>
</div>

<div class="article-image" style="background-image: url('assets/images/ed1.jpg')"></div>
</a>

CSS:

#main-content .education .article {
display: block;
height: 100%;
position: relative;
z-index: 1;
padding: 0;
text-decoration: none;
overflow: hidden;
}

#main-content .education .article .article-overlay {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 2;
transition: all 0.5s;
background-color: rgba(0, 0, 0, 0.5);
}

#main-content .education .article:hover .article-overlay {
background-color: rgba(0, 0, 0, 0.35);
}

#main-content .education .article .article-image {
width: 100%;
height: 100%;
position: relative;
background-position: center;
-webkit-transform: scale(1) rotate(0deg);
transform: scale(1) rotate(0deg);
transition: all 0.5s;
-webkit-background-size: cover;
-moz-background-size: cover;
background-size: cover;
}

#main-content .education .article:hover .article-image {
-webkit-transform: scale(1.2) rotate(2deg);
transform: scale(1.2) rotate(2deg);
}

#main-content .education .article .article-content {
z-index: 3;
color: #fff;
position: relative;
text-align: center;
position: absolute;
width: 60%;
top: 50%;
left: 50%;
-webkit-transform: translate(-50%, -100%);
transform: translate(-50%, -100%);
}

#main-content .education .article .article-content h2 {
text-transform: uppercase;
font-weight: 700;
font-size: 22px;
letter-spacing: 1px;
line-height: 40px;
position: relative;
padding-top: 20px;
margin: 0;
}

#main-content .education .article .article-content h2:before {
content: "";
display: block;
width: 150px;
height: 6px;
background-color: #bedb39;
position: absolute;
top: 0;
left: 50%;
margin-left: -75px;
}

#main-content .education .article .article-content h6 {
font-weight: normal;
text-transform: uppercase;
font-size: 16px;
position: relative;
padding-top: 20px;
margin: 0;
}

#main-content .education .article .article-content h6:before {
content: "";
display: block;
width: 150px;
height: 2px;
background-color: #fff;
position: absolute;
top: 0;
left: 50%;
margin-left: -75px;
}

现场演示:

http://amarsyla.com/sandbox/codo/education.html

最佳答案

好的,这是因为 z-index,从 #main-content .education .article 中清除 z-index,您可以将 z-index 设置为 .logo.social-icons 例如 20 用于放在前面。

#main-content .education .article {
display: block;
height: 100%;
position: relative;
padding: 0;
text-decoration: none;
overflow: hidden;
}

#header .logo, #header .social-icons {
z-index: 20;
}

关于html - 使用 2D 变换时的 1px 白线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30627753/

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