Size the DIV to the size of the background image

后端 未结 3 740
失恋的感觉
失恋的感觉 2020-12-06 23:01

I have a DIV with the following style

.vplayer-container .logo
{
 position: absolute;
 bottom: 50px;
 right: 10px;
 background: url(../img/logo.png) no-repea         


        
3条回答
  •  孤街浪徒
    2020-12-06 23:49

    CSS can't do this, the div gets its dimensions from the content within it. The background image is purely a mark of styling.

    You should be able to do this with Javascript, finding the height and width values and injecting them into an inline style should do it :)

    You can also use an tag within the .logo div. This would produce what you intend.

提交回复
热议问题