Overlay over image on hover

I am unsure of what I am doing wrong trying to get a transparent overlay to appear over an image on hover. Initially, I attempted a javascript approach, but that didn't work, so I figured I would try a more light-weight css approach.

Does anyone see why this is not working?

<div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code">

.section2-box {
  display: inline-block;
  width: 50%;
  height: 50%;
  border-bottom: 4px solid #FFF;
  border-right: 4px solid #FFF;
  box-sizing: border-box;
  position: relative;
}
.fadeHover {
  transition: all .35s ease;
  -webkit-transition: all .35s ease;
  transition-delay: 0.10s;
  -webkit-transition-delay: 0.10s;
  height: 100%;
  width: 100%;
  top: 0;
  left: 0;
  right: 0;
}

.fadeHover:hover .overlay {
  background-color: rgba(0, 0, 0, 0.6);
  z-index: 1;
  height: 100%;
  width: 100%;
  top: 0;
  left: 0;
  right: 0;
  position: absolute;
  cursor: pointer;
}

.fadeHover-title {
	font-family: 'Raleway', sans-serif;
	font-weight: 600;
	font-size: 1.3rem;
	color: #FFF;
	display: none;
}
.fadeHover-title.activeHover {
	opacity: 1;
}
.fadeHover-description {
	font-size: 1.1rem;
	color: #FFF;
	font-family: 'Open Sans', sans-serif;
	display: none;
}
.fadeHover-description.activeHover {
	opacity: 1;
}	
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<div class="section2-box fadehover" id="section2box3">
  <img src="https://upload.wikimedia.org/wikipedia/commons/thumb/e/eb/Ash_Tree_-_geograph.org.uk_-_590710.jpg/220px-Ash_Tree_-_geograph.org.uk_-_590710.jpg">
  <div class="overlay">
    <h2 class="fadeHover-title">Option 1</h2>
    <h3 class="fadeHover-description">Description</h3>
  </div>
</div>


Answer1:

Regardinf your question on the comment : change the text color of the element from a rgba with 0 alpha to a 1 alpha:

<div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code">

.section2-box {
  display: inline-block;
  width: 50%;
  height: 50%;
  border-bottom: 4px solid #FFF;
  border-right: 4px solid #FFF;
  box-sizing: border-box;
  position: relative;
}
.fadeHover {
  transition: all .35s ease;
  -webkit-transition: all .35s ease;
  transition-delay: 0.10s;
  -webkit-transition-delay: 0.10s;
  height: 100%;
  width: 100%;
  top: 0;
  left: 0;
  right: 0;
}

.fadeHover .overlay {
  z-index: 1;
  height: 100%;
  width: 100%;
  top: 0;
  left: 0;
  right: 0;
  position: absolute;
  cursor: pointer;
}

.fadeHover-title {
	font-family: 'Raleway', sans-serif;
	font-weight: 600;
	font-size: 1.3rem;
	color: rgba(255,255,255,0);
  transition: color 0.5s;
}

.fadeHover:hover .fadeHover-title {
	color: rgba(255,255,255,1);
}
.fadeHover-description {
	font-size: 1.1rem;
	color: rgba(255,0,0,0);
  transition: color 0.5s;
}
.fadeHover:hover .fadeHover-description {
	color: rgba(255,0,0,1);
}
<div class="section2-box fadeHover" id="section2box3">
  <img src="https://upload.wikimedia.org/wikipedia/commons/thumb/e/eb/Ash_Tree_-_geograph.org.uk_-_590710.jpg/220px-Ash_Tree_-_geograph.org.uk_-_590710.jpg">
  <div class="overlay">
    <h2 class="fadeHover-title">Option 1</h2>
    <h3 class="fadeHover-description">Description</h3>
  </div>
</div>


人吐槽 人点赞

Recommend

Comment

用户名: 密码:
验证码: 匿名发表

你可以使用这些语言

查看评论:Overlay over image on hover