CSDN页面完美格式打印

如果直接在CSDN页面上Ctrl + P打印,肯定会是页面显示不全,格式不正确,等等。
这是因为页面的CSS等元素干扰了打印。只要把那些干扰元素删除,再打印就OK了。

  1. 打开Chrome或者Firefox的开发者工具的console。(设置->更多工具->开发者工具)
  2. 将代码粘贴到console中,回车。如下:
(function(){
    $("#side").remove();
    $("#comment_title, #comment_list, #comment_bar, #comment_form, .announce, #ad_cen, #ad_bot").remove();
    $(".nav_top_2011, #header, #navigator").remove();
    $(".csdn-side-toolbar,.template-box,.reward-user-box").remove();
    $(".p4course_target, .comment-box, .recommend-box, #csdn-toolbar, #tool-box,#dmp_ad_58").remove();
    $("aside").remove();
    $(".tool-box").remove();
    $("main").css('display','content');
    $("main").css('float','left');
    $("#mainBox").css('width','1048px');
    $("#mainBox").css('margin-left','0px');
    $("#mainBox").css('margin-right','0px');
    //$("[class='main_father clearfix d-flex justify-content-center']").css("width","1048px");
    $(".main_father.clearfix.d-flex.justify-content-center").css("width","1048px");
    window.print();
    $("tool-box").remove();
    })();

来源于网络,侵删

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容