Place background image 1em from the right?

后端 未结 4 1014
抹茶落季
抹茶落季 2021-02-12 21:58

As far as I can tell, it is not possible to place a CSS background image 1em from the right border of any block, neither is it possible to place a image 1em from the bottom.

4条回答
  •  终归单人心
    2021-02-12 22:42

    The CSS3 background-position spec allows you to change the anchor point from the top left to anything you want. For example, the following will set the lower bottom corner of the image 1em from the right and 2px from the bottom:

    background-position: right 1em bottom 2px;
    

    Confirmed to work in:

    IE9/10, Firefox 13+, Chrome 26+, Opera 11+, Seamonkey 2.14+, Lunascape 6.8.0

    As of April 2013, only IE6-8 and some fringe browsers lack support.

    Here's a test page: http://jsbin.com/osojuz/1/edit

提交回复
热议问题