Posted By

michellebracken on 08/18/11


Tagged


Versions (?)

Setting Padding on Background Images


 / Published in: CSS
 

Since background images don’t create a new CSS box you can’t directly set padding on them. What you want to do is use the background-position property on the background image to create the same effect.

Top values can be top, center, or bottom and Left values can be left, center, or bottom Both can also take values in % or px or any other measurement. So to create 5px of padding around a background image you would use:

  1. 1 background-position {
  2. 2 top-value left-value;
  3. 3 }
  4.  
  5.  
  6.  
  7.  
  8. 1 {background-position: 5px 5px}

Report this snippet  

You need to login to post a comment.