I have a dynamic JS code that changes the background image of div
on each click. How can I change div
height and width dependent on the image size?
Here is my code for better understanding my problem:
element.style {
background: rgba(0, 0, 0, 0) url("../wp-content/uploads/ssf-wp-uploads/images/24/image.jpg") no-repeat scroll center center;
cursor: pointer;
height: 150px;
position: relative;
}
Here I set a fix size 150px
but background image size can change. So I want to set div
height depending on background image height .