html - icon center align vertically and horizontally -


i trying vertically , horizontally center align small icon putting on top of image.

relevant html part:

<li>     <a href="#">         <span class="test fa fa-play"></span>         <img src="thumbnail1-l.jpg" alt="">     </a> </li> <li>     <a href="#">         <span class="test fa fa-play"></span>         <img src="thumbnail2-l.jpg" alt="">     </a> </li> <li>     <a href="#">         <span class="test fa fa-play"></span>         <img src="thumbnail3-l.jpg" alt="">     </a> </li> <li>     <a href="#">         <span class="test fa fa-play"></span>         <img src="thumbnail4-l.jpg" alt="">     </a> </li>  

css part

.photo-list.cols-2 li {     width: 50%; } .photo-list li {     float: left;     width: 25%;     padding: 8px;     opacity: .8;     transition: opacity .3s ease-in-out; } .test{     position: absolute;     z-index: 1000000000;     font-size: 30px;     width: 60px;     height: 60px;     color: #fff;     display: flex;     justify-content: center;     align-items: center; } 

the output looks following: enter image description here

i appreciate how can align icons right. thanks!

put img tag in div of container class, , give left:50%; , top:50%; property img.see example code below:

<!doctype html>   <html>     <head>       <style>       .container {         position: relative;         width: 50%;       }        .image {         display: block;         width: 100%;         height: auto;       }         .text {         color: white;         font-size: 20px;         position: absolute;         top: 50%;         left: 50%;         transform: translate(-50%, -50%);         -ms-transform: translate(-50%, -50%);         z-index:1;       }       </style>     </head>     <body>     <div class="container">       <img src="img_avatar.png" alt="avatar" class="image">       <div class="text">kiran</div>     </div>   </body> </html> 

Comments

Popular posts from this blog

python - How to insert QWidgets in the middle of a Layout? -

python - serve multiple gunicorn django instances under nginx ubuntu -

module - Prestashop displayPaymentReturn hook url -