Set size on background image with CSS?

后端 未结 18 1775
野性不改
野性不改 2020-11-22 12:38

Is it possible to set the size of the background image with CSS?

I want to do something like:

background: url(\'bg.gif\') top repeat-y;
background-si         


        
18条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-11-22 13:23

    You can use two

    elements:

    • One is a container (it is the one which you originally wanted the background image to appear at).

    • The second one is contained within. You set its size to the size of the background image (or the size you wish to be appearing).

    The contained div is then set to be positioned absolute. This way it does not interfere with the normal flow of items in the containing div.

    It enables you to use sprite images efficiently.

提交回复
热议问题