jq jqprint 设置页脚_jquery.jqprint-0.3.js打印功能 以及页眉页脚设置显示与否
项目中需要打印 搜索使用了jquery.jqprint-0.3.js
遇到一些样式问题,现在已经解决 ,记录下来供大家参考。
下面图显示为我页面中的样式:满足需要根据设备名称输入的多少自动适应打印页面
项目引入
">
下面的引入显示在页面
">
下面的引入需要设置media="print" 这样只显示在打印的时候
">
下面的样式只在页面显示打印不显示
.prints{
font-size:13px;
}
.prints h5{
font-size:16px;
}
布局
适应设备名称的js
var max=0,max1=0,max2=0,max3=0,max4=0;
$(".prints ul li").each(function(){
$(this).height("auto").css("lineHeight","30px");
if($(this).children("div")[0]){
$(this).children("div").css("marginTop","0");
}
});
$(".prints ul:nth-child(2) li").each(function(){
if($(this).height()>max){
max=$(this).height();
}
});
$(".prints ul:nth-child(2) li").each(function(){
$(this).height(max).css("lineHeight",max+"px");
if($(this).children("div")[0]){
var h_=$(this).children("div").height();
$(this).children("div").css("marginTop",(max-h_)/2);
}
});
$(".prints ul:nth-child(3) li").each(function(){
if($(this).height()>max1){
max1=$(this).height();
}
});
$(".prints ul:nth-child(3) li").each(function(){
$(this).height(max1).css("lineHeight",max1+"px");
if($(this).children("div")[0]){
var h_=$(this).children("div").height();
$(this).children("div").css("marginTop",(max1-h_)/2);
}
});
$(".prints ul:nth-child(4) li").each(function(){
if($(this).height()>max2){
max2=$(this).height();
}
});
$(".prints ul:nth-child(4) li").each(function(){
$(this).height(max2).css("lineHeight",max2+"px");
if($(this).children("div")[0]){
var h_=$(this).children("div").height();
$(this).children("div").css("marginTop",(max2-h_)/2);
}
});
$(".prints ul:nth-child(5) li").each(function(){
if($(this).height()>max3){
max3=$(this).height();
}
});
$(".prints ul:nth-child(5) li").each(function(){
$(this).height(max3).css("lineHeight",max3+"px");
if($(this).children("div")[0]){
var h_=$(this).children("div").height();
$(this).children("div").css("marginTop",(max3-h_)/2);
}
});
$(".prints ul:nth-child(6) li").each(function(){
if($(this).height()>max4){
max4=$(this).height();
}
});
$(".prints ul:nth-child(6) li").each(function(){
$(this).height(max4).css("lineHeight",max4+"px");
if($(this).children("div")[0]){
var h_=$(this).children("div").height();
$(this).children("div").css("marginTop",(max4-h_)/2);
}
});
打印代码
$("#showPrint-table").jqprint({});
jquery-print.css的样式
*{
box-sizing:border-box;
}
.prints{
font-size:16px;
background-color: #84cdf7;
color:#000;
border:1px solid #000;
}
.prints ul{
overflow:hidden;
padding:0;
margin:0;
}
.prints ul li{
line-height:30px;
float:left;
list-style: none;
}
.prints h5{
font-size:18px;
text-align:center;
line-height:46px;
margin:0;
}
.prints ul li:nth-child(1){
width:20%;
text-align:justify;
text-justify:distribute-all-lines;
text-align-last:justify;
-moz-text-align-last:justify;
-webkit-text-align-last:justify;
padding:0 10px;
border-top:1px solid #000;
}
.prints ul li:nth-child(2){
width:30%;
text-align:center;
border-left:1px solid #000;
border-top:1px solid #000;
padding:0 10px;
background:#fff;
}
.prints ul li:nth-child(3){
width:20%;
text-align:justify;
text-justify:distribute-all-lines;
text-align-last:justify;
-moz-text-align-last:justify;
-webkit-text-align-last:justify;
padding:0 10px;
border-left:1px solid #000;
border-top:1px solid #000;
}
.prints ul li:nth-child(4){
width:30%;
text-align:center;
border-top:1px solid #000;
border-left:1px solid #000;
padding:0 10px;
background:#fff;
}
.prints ul li.danwei{
width:80%;
padding:0 10px;
background-color: #84cdf7;
}
.prints ul li div{
word-wrap:break-word;
line-height:30px !important;
}
jquery.jqprint-0.3.js代码
(function($) {
var opt;
$.fn.jqprint = function (options) {
opt = $.extend({}, $.fn.jqprint.defaults, options);
var $element = (this instanceof jQuery) ? this : $(this);
if (opt.operaSupport && $.browser.opera)
{
var tab = window.open("","jqPrint-preview");
tab.document.open();
var doc = tab.document;
}
else
{
var $iframe = $("");
if (!opt.debug) { $iframe.css({ position: "absolute", width: "0px", height: "0px", left: "-600px", top: "-600px" }); }
$iframe.appendTo("body");
var doc = $iframe[0].contentWindow.document;
}
if (opt.importCSS)
{
if ($("link[media=print]").length > 0)
{
$("link[media=print]").each( function() {
doc.write("");
});
}
else
{
$("link").each( function() {
doc.write("");
});
}
}
if (opt.printContainer) { doc.write($element.outer()); }
else { $element.each( function() { doc.write($(this).html()); }); }
doc.close();
(opt.operaSupport && $.browser.opera ? tab : $iframe[0].contentWindow).focus();
setTimeout( function() { (opt.operaSupport && $.browser.opera ? tab : $iframe[0].contentWindow).print(); if (tab) { tab.close(); } }, 1000);
}
$.fn.jqprint.defaults = {
debug: false,
importCSS: true,
printContainer: true,
operaSupport: true
};
// Thanks to 9__, found at http://users.livejournal.com/9__/380664.html
jQuery.fn.outer = function() {
return $($('
}
})(jQuery);
下面为谷歌显示的打印效果,可以勾除页眉页脚设置
火狐浏览器需要这样设置页眉页脚 打印--》页面设置 设置完以后打印效果一样
jq jqprint 设置页脚_jquery.jqprint-0.3.js打印功能 以及页眉页脚设置显示与否相关推荐
- js 打印的一些技巧 去除页眉页脚,主动分页
1.页眉页脚 可以简单点用css来实现 下拉把以下代码粘贴到页面里就可以了测试对于ie firefox chrome兼容都还不错 <style media="print"&g ...
- vue实现打印功能,并多页打印
一.下载 网上的源码只能打印一页,这个源码是修改过的可以直接保存使用 全选复制 另存为print.js // 打印类属性.方法定义 /* eslint-disable */ const Print = ...
- php 设置跨域axios,vue2.0中proxyTable用axios进行跨域请求的设置方法
vue2.0设置proxyTable使用axios进行跨域请求的方法 这里请求的是知乎日报的api,由@izzyleung这位大神提供的,这是github地址. 在vue-cli构建的项目中先安装ax ...
- Autodesk Meshmixer 2.0增强3D打印功能
转自http://maker8.com/article-277-1.html 来自天工社 maker8.com Autodesk发布了Meshmixer软件的一个新版本.Meshmixer是把应用重点 ...
- Web中 C-Lodop 打印常用表单前端排版自定义设置;
常用的打印设置:使用C-Lodop插件实现常用单据打印功能:以常用订货单和调拨单为例设置打印功能: 需要下载Lodop 打印的插件:http://www.lodop.net/download.html ...
- excel打印预览在哪里_在excel表格的打印预览界面调整页边距
我们一般在打印excel表格之前都会查看一下打印预览,看看哪里有出错的问题没有,我们在excel打印预览里面如果看到页边距不合适,那么我们可以在excel表格的打印预览界面调整页边距,具体的调整页边距 ...
- jq jqprint 设置页脚_jQuery 插件 jqprint 实现浏览器页面打印和设置页眉页脚
使用 jqprint 插件实现浏览器页面打印,需要用到两个js文件,jquery.js 和 jqprint.js,本文使用 jquery-1.4.4.min.js,jquery.jqprint-0.3 ...
- jqprint打印时自定义页眉页脚
需求:自定义页眉,实现打印时分页时每页页眉都显示相同的信息 打印所用插件jqprint 解决方法: <div class="divHeader"> <span s ...
- WebBrowser 打印设置,打印预览,去页眉和页脚
WebBrowser是IE内置的浏览器控件,无需用户下载. 一.WebBrowser控件 <object ID='WebBrowser' WIDTH=0 HEIGHT=0 CLASSID='CL ...
最新文章
- SolidWorks大师班:从基础到专业学习教程
- 推荐|深度学习领域引用量最多的前20篇论文简介
- 2017-08-10 前端日报
- 避免从单体到分布式单体
- Remainders Game (中国剩余定理)
- idea Cannot Resolve Symbol 不能找到别的包中的类 能找到自己包中的类
- java 动态树_使用dtree构建动态树型菜单
- 设计模式-策略模式(Strategy)
- ASP.NET Report Starter Kit视频教程--1
- PM2怎么保持Node应用程序永久活动?
- OpenJudge 2990:符号三角形 解析报告
- python环境下数据操作_在windows环境下使用Python操作spatialite数据库
- [JavaScript实例解析]js计算器
- net share命令删除共享
- ABAP中如何建数据库视图和维护视图
- 情商高的人所看透的四种人生真相
- python检测ipa证书过期时间
- 迅歌KTV服务器各型号,2017年ktv必点歌曲排行榜(4页)-原创力文档
- iOS 给APP评分无法连接到App Store解决方法
- OpenLayers 6 如何优雅的使用天地图WMTS服务“经纬度投影(CGCS2000)”和“球面墨卡托投影(EPSG:3857)”
热门文章
- 服务器更换主板后linux系统无法启动解决
- 怎么让html自动刷新,“360浏览器怎么设置自动刷新网页解决方案”的解决方案...
- 字符串删除多余*号问题
- 有源音箱和无源音箱哪个好
- 计算机过程控制系统实例ppt,chap7 前馈控制系统_武汉理工大学:调节仪表与过程控制系统_ppt_大学课件预览_高等教育资讯网...
- openrov爱好者
- 公司的到一个B类地址块,需要划分成若干个包含1000台主机的子网,则可以划分成几个?...
- 曾经的豪言壮语,如今的喟然长叹
- Springboot+poi实现浏览器下载excel文件
- H5 拖放drag跟drop