Set divs height and width according to width and height of background image

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • farrukhm
    New Member
    • Apr 2010
    • 1

    Set divs height and width according to width and height of background image

    Hi There,

    I just want to know that either it is possible to set height/width of div/li etc according to width and height of their background image automatically?

    For example if i set the background 40 x 40 image. Div height width should automatically become 40 x 40.
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    I’m not aware, that it is possible with HTML/CSS only. I can imagine JavaScript to be of help (if you have the image’s naturalWidth/naturalHeight attributes available)

    Comment

    Working...