admin 发表于 2023-3-11 16:36:40

Discuz! X3.5手机自适应网页代码


[*]后台 全局->SEO 设置->其他->其他头部信息 放入如下代码:
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no, viewport-fit=cover">

<style>
body, #toptb {min-width: 0 !important}
.wp {width: 1200px !important; max-width: 100% !important}
img.zoom, #e_image_menu {max-width: 100% !important; height: auto !important}
.btn_s_open, .btn_s_close, #qmenu {display: none !important}
.pcht {max-width: 100%}
.a_t td {padding: 4px !important}
.attach_nopermission {width: 100% !important; max-width: 600px !important}

/*send msg btn*/
/*ul.xl.xl2.o.cl { display: none !important }*/

dl:has(a) {display: none}

@media (max-width: 767px) {
    .m_c .tedt, #subjecthide, .m_c .quote, .rfm {width:100% !important}
    #frt, .fl_i, .num, #boardlogo, .category_l3, .pls, tr td:nth-last-child(3).by, tr.ts td:nth-last-child(-n+2) {display: none !important}
    #scbar_txt, .ct2_a .mn, .f_c.altw, .c, .f_c .list {width: auto !important}
    .rfm th {width: 5em !important}
    .pm {width: 360px !important}
    .ptm img {max-width: 100% !important}
    #forumnewshow {display: none !important}
    .pt.mtn {max-width: 300px !important}
    .el.mtm.cl {width: auto !important}
}

@media (max-width: 392px) {
    .fl_by {display: none !important}
}

@media (max-width: 1209px) {
    #wp, #ft, .hdc.cl {padding: 0 10px !important; box-sizing: border-box}
}
</style>

<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-5RJRHQRN9W"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-5RJRHQRN9W');
</script>

<script>
document.addEventListener("DOMContentLoaded", function() {
    if (!document.querySelector(".vwmy")) {
      var script = document.createElement('script');
      script.async = true;
      script.src = 'https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-4437995878589892';
      script.setAttribute('crossorigin', 'anonymous');
      document.head.appendChild(script);
    }

    const mobileWidth = 767
    if (window.innerWidth<=mobileWidth) {
      if (!document.cookie.includes('close_leftinfo=1')) {
      setcookie('close_leftinfo', 1)
      location.reload()
      }
    } else {
      if (document.cookie.includes('close_leftinfo=1')) {
      setcookie('close_leftinfo', 2)
      location.reload()
      }
    }
   
    const form = document.getElementById('scbar_form');
    form.querySelectorAll('input').forEach(function(input) { input.parentNode.removeChild(input); });
    form.removeAttribute('method');
    form.setAttribute('action', 'https://www.google.com/search');
    const scbarBtn = document.getElementById('scbar_btn');
    scbarBtn.setAttribute('name', 'as_sitesearch');
    scbarBtn.setAttribute('value', 'shuzijumin.com');
    document.getElementById('scbar_txt').setAttribute('name', 'q');

    document.getElementById('e_switchercheck')?.click()
});
</script>

[*]站点宽窄风格改成窄屏(固定宽度),允许用户自由切换改成否
[*]作者用户名显示位置改成显示在帖子内部
[*]快速发帖右侧显示推荐表情改成否
[*]左侧信息栏允许用户控制 改为 是
[*]仅适用于Discuz! X3.5默认主题,不适用3.4
页: [1]
查看完整版本: Discuz! X3.5手机自适应网页代码