css - How to set a div size to its background image size -


<div class="newsblocks"></div> 

css:

.newsblocks{      background: url(../img/news/1.png); } 

how set div size of 1.png?

it's not possible auto-size div based on size of it's background image, (hacky) way, including img tag url image, setting img visibility:hidden; [used inline css brevity - don't kill me!]:

<div style="background-image: url('img.jpg');">     <img src="img.jpg" style="visibility:hidden"/> </div 

Comments

Popular posts from this blog

jQuery Mobile app not scrolling in Firefox -

c++ - How to add Crypto++ library to Qt project -

php array slice every 2th rule -