/ Published in: HTML
                    
                                        
                            
                                Expand |
                                Embed | Plain Text
                            
                        
                        Copy this code and paste it in your HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
<head>
<style type="text/css">
.vcenter span{
line-height: 24px;
/*
grâce àcette astuce le span va se comporter comme une image, ainsi la propriété 'vertical-align' pourra agir sur lui
*/
display: inline-block;
/*
... on align le text verticalement au centre
RMQ : pour un alignement en bottom il faudra modifier le line-height de l'element vcenter de manière àce qu'il soit plus ou moins le double d'une line-height actuel
*/
vertical-align: middle;
}
.vcenter{
margin: 0;
line-height: 200px;
}
.conteneur{
height: 200px; //la configuration du conteneur avec une hauteur et overflow en hidden àson importance si on ne veut pas voir les elements qui suivent être poussé vers le bas
overflow-y: hidden;
width: 500px;
border: 1px red solid;
}
</style>
</head>
<body>
<div class="conteneur">
<p class="vcenter">
<span>
<img src="http://www.w3schools.com/images/h_logo.gif">Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl
</span>
 
</p>
</div>
</body>
</html>
Comments
 Subscribe to comments
                    Subscribe to comments
                
                