热搜词

我的博客

版块简介:一些简单的介绍
  •  57帖子
  •  151讨论
  •  0关注

Discuz!X3.4自带pc端模板自适应手机端方法

邱双仪 发表于 2023-6-12 02:18:21 | 显示全部楼层 |阅读模式
1037 0
discuz!自带的pc端模板挺不错的,只要用小面的代码就可以把pc端的原版自适应到手机端。代码放到后台统计里就可以了。

  1. <script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.slim.min.js"></script>
  2. <script>var jq = jQuery.noConflict();</script>
  3. <script>
  4. jq(document).ready(function () {
  5. jq("head").append('<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">')
  6. jq("head").append('</p>
  7. <style>.tedt{width:100% !important; max-width:600px}</style>
  8. <p>')
  9. jq("head").append('</p>
  10. <style>.quote{width:100% !important}</style>
  11. <p>')
  12. jq("#toptb").css("min-width", "0")
  13. jq(".hdc.cl").css("min-height", "0")
  14. jq(".wp").css("min-width", "0")
  15. jq(".zoom").css("width", "100%")
  16. jq(".zoom").css("max-width", "600px")
  17. jq(".attach_nopermission.attach_tips").css("width", "100%")
  18. jq(".attach_nopermission.attach_tips").css("max-width", "600px")
  19. jq(".tedt.mtn").css("width", "100%")
  20. jq(".tedt.mtn").css("max-width", "600px")
  21. jq("#scrolltop").children("span:eq(0)").children("a").attr("onclick", "void(0)")
  22. resized()
  23. })
  24. window.addEventListener("resize", resized)
  25. function resized() {
  26. if (jq(document).width() <= 650) {
  27. jq("#online").hide()
  28. jq("#qmenu").hide()
  29. jq("#um").children("p:eq(1)").hide()
  30. jq("#um").css("padding-right", "0")
  31. jq("#scbar_txt").css("width", "calc(100vw - 145px)")
  32. jq(".scbar_hot_td").hide()
  33. jq(".fl_i").hide()
  34. jq(".fl_by").hide()
  35. jq(".hdc.cl").children("h2").children("a").children("img").css("height", "32px")
  36. jq("#chart").hide()
  37. jq("#loginstatus").hide()
  38. jq(".avt.y").hide()
  39. jq(".y.pns").children("table").children("tbody").children("tr:eq(0)").hide()
  40. jq(".y.pns").children("table").children("tbody").children("tr:eq(1)").children("td:eq(0)").hide()
  41. jq(".y.pns").children("table").children("tbody").children("tr:eq(1)").children("td:eq(1)").hide()
  42. jq("#frt").hide()
  43. jq(".by").hide()
  44. jq(".num").hide()
  45. jq(".bm_h.cl").children(".y").hide()
  46. jq("#toptb").children(".wp").children(".y").hide()
  47. jq(".pls").hide()
  48. jq("#fj").hide()
  49. jq("#fastsmiliesdiv").hide()
  50. jq("#fastposteditor").css("margin-right", "0")
  51. jq("#p_btn").hide()
  52. } else {
  53. jq("#online").show()
  54. jq("#qmenu").show()
  55. jq("#um").children("p:eq(1)").show()
  56. jq("#um").css("padding-right", "60px")
  57. jq("#scbar_txt").css("width", "400px")
  58. jq(".scbar_hot_td").show()
  59. jq(".fl_i").show()
  60. jq(".fl_by").show()
  61. jq(".hdc.cl").children("h2").children("a").children("img").css("height", "66px")
  62. jq(".pipe").show()
  63. jq("#chart").show()
  64. jq("#loginstatus").show()
  65. jq(".avt.y").show()
  66. jq(".y.pns").children("table").children("tbody").children("tr:eq(0)").show()
  67. jq(".y.pns").children("table").children("tbody").children("tr:eq(1)").children("td:eq(0)").show()
  68. jq(".y.pns").children("table").children("tbody").children("tr:eq(1)").children("td:eq(1)").show()
  69. jq("#frt").show()
  70. jq(".by").show()
  71. jq(".num").show()
  72. jq(".bm_h.cl").children(".y").show()
  73. jq("#toptb").children(".wp").children(".y").show()
  74. jq(".pls").show()
  75. jq("#fj").show()
  76. jq("#fastsmiliesdiv").show()
  77. jq("#fastposteditor").css("margin-right", "170px")
  78. jq("#p_btn").show()
  79. }
  80. }
  81. </script>
复制代码


全部评论

暂无评论,期待您打破宁静

您需要登录后才可以回帖 登录 | 注册
发表评论
发布 联系QQ