【发布时间】:2017-07-21 10:43:49
【问题描述】:
我正在尝试在悬停时为我的图像添加半透明叠加层。为了达到如下效果,我写了代码:
我想知道只有当用户将鼠标悬停在图像上时,我才能摆脱“数据仓库”文本。这是我的代码:
CSS:
.overlay {
display: block;
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
height: 100%;
width: 100%;
opacity: 0;
transition: .5s ease;
background-color: #5e8cc9;
z-index: 99;
}
.text {
text-align: center;
color: white;
font-size: 60px;
font-family: raleway;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
z-index: 100;
}
.title {
z-index: 98;
}
.container1:hover .overlay {
opacity: .9;
}
.container1:hover .title {
opacity: 0;
}
HTML:
<div class="overlay">
<div class="text">
<p style="text-align: center; font-size: 18px;">
<span style="color: #ffffff; font-weight: 200;">Cloud-Based | Single Tenant | Mosaic will operationalize warehouse in weeks with no start up cost | Mosaic takes care of all hosting, licensing and maintenance | Mosaic manages day to day operations | Highly flexible scalable warehouse model accommodates long-term evolution of data portfolio and sales operations | Mosaic implements new data sets and new requirements on demand</span></p>
</div>
</div>
<div class="title">
<h1 style="font-size: 56px; text-align: center; position: relative; top: 50%; line-height: 65px;"><span style="color: #ffffff; font-weight: 600;">Data Warehouse</span></h1>
</div>
唯一的问题是当我制作时
.container1:hover .title {
opacity: 0;
}
,标题文本和覆盖被删除。 我确信它是一个简单的修复,但任何帮助将不胜感激。谢谢
【问题讨论】:
-
您的 css 正在使用选择器 .container1 但您没有在 html 中的任何地方使用该类