Home > database >  CSS3 div onhover show display delete icon, no javascript, pure CSS3
CSS3 div onhover show display delete icon, no javascript, pure CSS3

Time:10-02

.img-wrap {
    position: relative;
    display: inline-block;
}
.img-wrap .close {
    position: absolute;
    top: 2px;
    right: 2px;
    z-index: 5;
    transition: opacity 0.15s ease-in;
    padding: 5px 2px 2px;
    color: #000;
    font-weight: bold;
    cursor: pointer;
    opacity: 0;
    text-align: center;
    font-size: 22px;
    line-height: 10px;
    border-radius: 50%;
}
.img-wrap:hover .close {
    z-index: 10;
    background-color: rgb(5 0 0 / 75%);
    opacity: 1;
}
<div class="img-wrap">
    <a href="" class="close float-right red rounded-lg p-2 mr-2 mt-2" title="DELETE"><i class="fas fa-trash-alt fa-lg text-white"></i></a>
    <div class="media">
       <i class="fal fa-file fa-4x icon-pdf d-flex mr-3"></i>
       <div class="media-body">
           <h6 class="mt-0 mb-0 grey-text  font-weight-bold">This is an existing File</h6>
           <div><small><b class="mr-2">File Name</b>
                <a href="" target="_blank">${filename}</a> 
                </small>
          </div>
       </div>
    </div>                          
</div>

div onhover show delete icon

☝️This is what I want to display, but ended up like this

  • Related