You can try using ::before
HTML
<ul id="content-ul"> <li> <a href="#" target="_blank" titulo="Lorem 1"> <img src="http://placehold.it/150x150" /> </a> </li> <li> <a href="#" target="_blank" titulo="Lorem 2"> <img src="http://placehold.it/150x150" /> </a> </li> <li> <a href="#" target="_blank" titulo="Lorem 3"> <img src="http://placehold.it/150x150" /> </a> </li> <li> <a href="#" target="_blank" titulo="Lorem 4"> <img src="http://placehold.it/150x150" /> </a> </li> </ul>
CSS
#content-ul{ display: block; width: 340px; margin: auto; overflow: hidden; } #content-ul li,#content-ul li a{ display: block; position: relative; width: 150px; height: 150px; float: left; overflow: hidden; } #content-ul li{ margin: 10px 10px ; } #content-ul li a{ text-decoration: none; color: #fff; font-size: 14px; text-shadow: 0 1px 0 #000; font-weight: bold; border-radius: 4px; } #content-ul li a img{ border-radius: 4px; } #content-ul li a:before{ visibility: hidden; content: attr(titulo); position: absolute; line-height: 250px; float: left; width: 150px; height: 150px; background: rgba(0,0,50,.5); border-radius: 4px; overflow: hidden; text-align: center; font-size: 25px; filter: alpha(opacity=0); opacity: 0; -webkit-transition: opacity 0.5s ease-out; -moz-transition: opacity 0.5s ease-out; -ms-transition: opacity 0.5s ease-out; -o-transition: opacity 0.5s ease-out; transition: opacity 0.5s ease-out; } #content-ul li a:hover::before{ -webkit-transition: opacity 0.2s ease-in; -moz-transition: opacity 0.2s ease-in; -ms-transition: opacity 0.2s ease-in; -o-transition: opacity 0.2s ease-in; transition: opacity 0.2s ease-in; zoom: 1; filter: alpha(opacity=100); opacity: 1.0; visibility: visible; }
Working demo
Here's an update based on your code:
HTML:
<div class="main"> <a href="" content="1Lorem Ipsum is simply dummy text of the printing and typesetting industry."> <img src="http://placehold.it/150x150"> </a> <a href="" content="2Lorem Ipsum is simply dummy text of the printing and typesetting industry."> <img src="http://placehold.it/150x150"> </a> <a href="" content="3Lorem Ipsum is simply dummy text of the printing and typesetting industry."> <img src="http://placehold.it/150x150"> </a> <a href="" content="4Lorem Ipsum is simply dummy text of the printing and typesetting industry."> <img src="http://placehold.it/150x150"> </a> </div>
CSS
.main{ position: relative; width: 300px; overflow:hidden } .main a{ width: 50%; height: 50%; float:left; } .main a:before{ visibility: hidden; content: attr(content); position: absolute; line-height: 250px; float: left; width: 150px; height: 150px; background: rgba(0,0,50,.5); border-radius: 4px; overflow: hidden; text-align: center; font-size: 25px; filter: alpha(opacity=0); opacity: 0; -webkit-transition: opacity 0.5s ease-out; -moz-transition: opacity 0.5s ease-out; -ms-transition: opacity 0.5s ease-out; -o-transition: opacity 0.5s ease-out; transition: opacity 0.5s ease-out; } .main a:hover::before{ -webkit-transition: opacity 0.2s ease-in; -moz-transition: opacity 0.2s ease-in; -ms-transition: opacity 0.2s ease-in; -o-transition: opacity 0.2s ease-in; transition: opacity 0.2s ease-in; zoom: 1; filter: alpha(opacity=100); opacity: 1.0; visibility: visible; }
Working demo
source share