center background image in any screen size if text is center-aligned - HTML CSS CSS Widget

HTML CSS examples for CSS Widget:Image Text Alignment

Description

center background image in any screen size if text is center-aligned

Demo Code

ResultView the demo in separate window

<html>
 <head> 
  <meta name="viewport" content="width=device-width, initial-scale=1"> 
  <style id="compiled-css" type="text/css">
p {<!--  w w  w .  j a v  a 2  s  . com-->
   text-align:center;
}

p .icon {
   background:url('https://www.java2s.com/style/demo/Google-Chrome.png') no-repeat 0 0;
   width:13px;
   height:13px;
   display:inline-block;
   margin-right:11px;
}
</style> 
 </head> 
 <body> 
  <p> <i class="icon"></i>Lorem ipsum dolor sit amet, consectetur </p>  
 </body>
</html>

Related Tutorials