jQuery Style How to - Make Div Background come over image








Question

We would like to know how to make Div Background come over image.

Answer


<!--from  w  ww .  j a  v  a 2 s .c  om-->
<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'
  src='http://code.jquery.com/jquery-1.9.1.js'></script>
<style type='text/css'>
.sxlm {
  width: 150px;
  height: auto;
  position: relative;
}

#changeImage {
  color: black;
  text-align: center;
  position: absolute;
  display: none;
  margin-top: -20px;
  width: 100%;
  bottom: 0;
  background-color: #EEE;
}
</style>
<script type='text/javascript'>//<![CDATA[ 
$(window).load(function(){
    $(".sxlm").hover(function () {
        $("#changeImage").slideToggle('show');
    })
});//]]>  
</script>
</head>
<body>
  <div class='sxlb'>
    <label class="control-label" for="textinput">Profile Picture:</label>
  </div>
  <div class="sxlm">
    <img src="http://www.java2s.com/style/download.png" />
    <div id="changeImage">
      <a href="#">Change Image</a>
    </div>
  </div>
</body>
</html>

The code above is rendered as follows: