Show image over another image on hover

后端 未结 4 984
春和景丽
春和景丽 2020-12-16 08:03

I have the following code: JSFiddle

HTML:

4条回答
  •  被撕碎了的回忆
    2020-12-16 08:18

    I got it myself to show an image in the center of another image on hover

    HTML:

    
      
        
      
    
      
    Profile Image
    default image

    CSS:

    .imageBox {
      position: relative;
      float: left;
    }
    
    .imageBox .hoverImg {
      position: absolute;
      left: 350px;
      top: 100px;
      display: none;
    
    }
    
    .imageBox:hover .hoverImg {
      display: block;
    }
    

    Note that left: 350px and top: 100px will be changed based on your background-image in my case background-image was 700x200(width x height). So in order to position the image to the center just take half of width and height.

提交回复
热议问题