【发布时间】:2018-07-13 01:28:22
【问题描述】:
我需要帮助来改进我的 CSS。我想在倾斜的 div 中制作悬停效果,而不影响放在 div 上的图像。
.overlay-box {
position: relative;
width: 150px;
height: 150px;
transform: skew(-10deg);
display: inline-block;
}
.overlay-box img {
height: 100%;
width: 100%;
}
.content {
position: absolute;
top: 0;
left: 0;
height: 100%;
width: 100%;
background-color: rgba(0, 0, 0, 0);
text-align: center;
padding-top: 50%;
opacity: 0;
transition: ease-in-out .7s background;
transition: ease-in-out .7s opacity;
}
.content:hover {
opacity: 1;
background-color: rgba(0, 0, 0, .8);
}
.info {
font-size: 6vh;
text-decoration: none;
}
.content a {
color: white;
text-decoration: none;
}
<div class="overlay-box">
<img src="img/bg1.jpg" alt="">
<div class="content">
<a href="#" class="info" title="Full Image">SERVIÇOS</a>
</div>
</div>
但是这段代码会影响我的背景图片,我如何倾斜我的 div 并且我的图片在正方形方面继续。
【问题讨论】:
-
您只希望文本倾斜?不是黑色背景吧?
标签: css hover css-transitions skew