table页面展示图片_(转载)html页面局部打印

本文主要介绍如何在HTML页面中实现表格内容的展示,并确保在进行局部打印时图片能够正确显示。针对表格中图片的显示问题,提供了解决方案。
摘要由CSDN通过智能技术生成
<style> <!-- 看起来好看一些 -->
.table .text-center, 
.table .text-center th,
.table .text-center td { text-align:center; }
.table thead th { vertical-align:middle; }
.shebao_fail { color:#e74c3c; text-decoration:line-through; }
.suspend { color:#F93;  text-decoration:line-through; }

/* print style */

    caption h2 { font-size:22px; }
    .table { font-family:"宋体"; }
    .table .nowrap { white-space:nowrap; word-break:break-all; }
    
    .table-bordered { border:1px solid #333; border-left:0px solid #333; border-collapse:collapse; }
    .table th, .table td { border: 1px solid #333; } 
    .table-bordered th, .table-bordered td { border: 1px solid #333; }
    .table>thead>tr>th { border-bottom: 0px solid #333; }
    
    .table-condensed th, .table-condensed td { padding:0px 5px; }   
    .qihai_logo { position:relative; }
    .qihai_logo_gray { position:absolute; left:0px; top:-5px; z-index:-1; }
    #article_content img{height:auto !important}
    #article_content {word-wrap: break-word;}
        .btn {margin-top: 33px;}
</style>

</head>
<body>
<div class="wrap js-check-wrap">
     <!--startprint-->
     <div id="article_content"> <!--需要展示的数据 自行修改 我用的tp-->
        {$result['post_content']}
     </div>
     <!--endprint-->
     <div class="form-actions">
        <a class="btn btn-primary" onClick="doPrint()">打印</a>
    </div>
</div>
<script type="text/javascript">   
<!--打印操作-->    
function doPrint() {    
        bdhtml=window.document.body.innerHTML;    
        sprnstr="<!--startprint-->";    
        eprnstr="<!--endprint-->";    
        prnhtml=bdhtml.substr(bdhtml.indexOf(sprnstr)+17);    
        prnhtml=prnhtml.substring(0,prnhtml.indexOf(eprnstr));    
        window.document.body.innerHTML=prnhtml; 
        window.print();    
        window.document.body.innerHTML=bdhtml; 
    }    
</script>
</body>
</html>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值