帝国cms7.5手机端图片不自动适配的处理方法
标签搜索

帝国cms7.5手机端图片不自动适配的处理方法

聚宝坊
2026-02-13 / 0 评论 / 2 阅读 / 正在检测是否收录...
1.在内容页模板<head> 和 </head>之间添加如下代码
<meta name="viewport" content="width=device-width, initial-scale=1.0">
   <style>
   img{max-width:100%!important;height:auto!important;width:auto!important}
   .newstext img,.content img{max-width:100%!important;height:auto!important;width:100%!important;display:block!important;margin:10px auto!important}
   </style>

2.在 </body> 标签前添加: 
<script>
   !function(){function i(){for(var i=document.getElementsByTagName("img"),t=0;t<i.length;t++)i[t].removeAttribute("width"),i[t].removeAttribute("height"),i[t].style.maxWidth="100%",i[t].style.height="auto"}"loading"===document.readyState?document.addEventListener("DOMContentLoaded",i):i(),window.addEventListener("load",i)}();
0

评论 (0)

取消