75729

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

  • Dynamic Allocation of an Array of Strings in C
  • Range slider endpoints are cut off in Firefox
  • SQL prototype design: facing silent truncation of data using varchar(N) — any better alternatives?
  • psql.frame_query
  • Networkx node sizes
  • Javascript Unit test
  • CSS - Cursor Transition
  • Fill value backwards from occurence by group
  • Functions returning a const value [duplicate]
  • Adding millions of nodes to neo4j spatial layer using cypher and apoc
  • Position absolute not working inside position fixed
  • CSS transition glitch
  • date: illegal option — d, Find difference between two dates
  • Animating an SVG Group
  • Unity 5.1 Animator Controller not transitioning
  • Spring Web Flow exception handling
  • UITableView takes much longer to load when numberOfRows returns a large number
  • Cursor in wrong place in contenteditable
  • Android - Calling Java from Webview
  • is it possible to insert a line break in this tooltip?
  • How to add closing tag for canvas in three js rendered Canvas?
  • countdown bar android example
  • Flex items with same property values are rendering in different sizes
  • Cut the background to expose the layer below
  • Jquery Mobile pageLoading() Method how does it work?
  • How to pass nginx proxy url for socket
  • how to display data from 1st point on words on y axis for line chart in d3.js
  • Listbox within Listbox and scrolling trouble in Windows Phone 7 Silverlight
  • Disable Enter in editText android
  • Change multiple background-images with jQuery
  • Algorithm for a smudge tool?
  • CSS Linear-gradient formatting issue accross different browsers
  • Update CALayer sublayers immediately
  • Can Jackson SerializationFeature be overridden per field or class?
  • Why doesn't :active or :focus work on text links in webkit? (safari & chrome)
  • How to check if every primary key value is being referenced as foreign key in another table
  • jquery mobile loadPage not working
  • RestKit - RKRequestDelegate does not exist
  • Android Studio and gradle
  • python regex in pyparsing