html默认样式:
<div class="news_infos" id="newsp">
<p><img src="/static/wddqxz/img/default/default.png" data-src="images/v1.jpg" style="width:300px;height:100px"></p>
</div>
CSS:
.news_infos img { max-width: 650px;height:auto; }
js:
<script type="text/javascript">
var aImg=document.getElementById("newsp").getElementsByTagName('img');
for(var i=0;i<aImg.length;i++){
aImg[i].style.height="100%";
aImg[i].style.width="100%";
}
</script>
或者 方法二:
<script type="text/javascript">
var aImg=document.getElementById("newsp").getElementsByTagName('img');
for(var i=0;i<aImg.length;i++){
aImg[i].style.height="auto";
aImg[i].style.width="auto";
}
</script>
html更改后:
<div class="news_infos" id="newsp">
<p><img src="/static/wddqxz/img/default/default.png" data-src="images/v1.jpg" style="width:100%;height:100%"></p>
</div>
方法三 CSS:
.news_infos img { max-width: 650px;height:auto; }
@media only screen and (max-width: 480px) {
.news_infos img { width:100%; }
}
正在阅读:
开展端午节主题活动的总结四篇12-30
领导给员工生日祝福语【三篇】04-22
2017高考数学知识点:三角函数的图形10-19
2018年贵州师范大学运动训练、武术与民族传统体育专业招生简章04-03
幽默儿童笑话故事文字版七篇10-05