html - Setting height of img tag equal to its width -


well googled lot didn't find useful.is there way achieve ?

<img src="1.jpg"height="" width="100%"> 

use offsetwidth:

var img = document.getelementsbytagname("img")[0];  img.style.height = img.offsetwidth + "px"; 

and have use javascript.

working demo


Comments

Popular posts from this blog

ios - Change Storyboard View using Seague -

inversion of control - Autofac named registration constructor injection -

verilog - Systemverilog dynamic casting issues -