我的编码问题是我希望图像标题在鼠标悬停时保持固定,但彩色背景只出现在标题下方而不是标题后面。如果我能让背景一直在标题后面,而不是在鼠标悬停在标题下方。我附上了几张图片,说明了当前的问题以及我希望的解决方案。我还附上了一些 HTML 和 CSS 编码示例,因此您也可以查看代码。谢谢!
.section{
margin-top: -70px;
margin-right: 225px;
margin-left: 217px;
}
/*Portfolio Gallery*/
.view {
position: relative;
margin: 10px 0px 10px 10px;
display: block;
float: left;
border: 10px solid #909090;
overflow: hidden;
text-align: center;
background-image: url("../images/over1.jpg");
border-radius: 50%;
-moz-box-shadow: inset 0 0 10px #000000;
-webkit-box-shadow: inset 0 0 10px #000000;
box-shadow: inset 0 0 10px #000000;
max-width: 30.26%;
height: 300px;
}
.view .mask,
.view .content {
overflow: hidden;
top: 0;
left: 0
}
.view h2 {
text-transform: uppercase;
text-decoration: underline;
border: 1px solid #000000;
color: #FFFFFF;
font-weight: 900;
text-align: center;
font-size: 30px;
padding: 10px;
background:#000000;
margin: 50px 0 0 0;
overflow: hidden;
}
.view p {
position: relative;
display: block;
font-family: Merriweather, serif;
font-style: italic;
font-size: 18px;
font-weight: 800;
color: #FFFFFF;
padding: 0px 10px 0px;
text-align: center;
text-shadow:
-1px -1px 0 #000,
1px -1px 0 #000,
-1px 1px 0 #000,
1px 1px 0 #000;
}
.view a.info {
font-size: 26px;
text-decoration: none;
padding: 10px 10px;
background: #000;
color: #fff;
font-family: Raleway, serif;
text-transform: uppercase;
box-shadow: 0 0 1px #000;
}
.view a.info:hover {
box-shadow: 0 0 5px #000
}
/*1*/
.view-first img {
/*1*/
transition: all 0.2s linear;
}
.view-first .mask {
position: relative;
display: block;
opacity: 0;
background-color: rgba(255,0,4,0.57);
transition: all 0.4s ease-in-out;
height: 100%;
}
.view-first h2 {
transform: translateY(1px);
opacity: 100;
transition: all 0.2s ease-in-out;
}
.view-first p {
transform: translateY(100px);
opacity: 0;
transition: all 0.2s linear;
}
.view-first a.info {
opacity: 0;
transition: all 0.2s ease-in-out;
}
/* */
.view-first:hover img {
transform: scale(1.1);
}
.view-first:hover .mask {
display: block;
opacity: 1;
}
.view-first:hover h2,
.view-first:hover p,
.view-first:hover a.info {
opacity: 1;
transform: translateY(0px);
}
.view-first:hover p {
transition-delay: 0.1s;
}
.view-first:hover a.info {
transition-delay: 0.2s;
}
<div class="section group">
<div class="view view-first">
<h2>LOGOS</h2>
<div class="mask">
<p>The Beginning Part Of The Branding Process.Logos I Have Done For Clients</p>
<a href="#" class="info">Click Here</a>
</div>
</div>
常规 View :
问题:
期望的结果:
最佳答案
问题是 .view-first .mask 类。
对于预期的结果,提到的类需要 POSITION:ABSOLUTE 而不是 RELATIVE。
.view-first .mask {
position: absolute;
display: block;
opacity: 0;
background-color: rgba(255,0,4,0.57);
transition: all 0.4s ease-in-out;
height: 100%;
}
这样做会达到预期的效果,但是会出现另一个问题。您将需要调整以下类的 margin-top:
.view-first p
.view a.info
关于html - 背景悬停不出现在标题后面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57949179/