Language/CSS
Responsive Image(반응형 이미지) 구현
beagle developer
2018. 4. 18. 16:39
HTML에 적용하고 싶을 때,
<img src="imgfilename.jpg" style="max-width: 100%; height: auto;">
CSS로 적용하고 싶을 때,
img
{
max-width: 100%;
height: auto;
}
+ JavaScript
var img = document.getElementsByTagName("img");
var i=0;
while (i < img.length) {
img[i].setAttribute("style", "max-width: 100%; height: auto;"); i++;
}