项目中需要打印 搜索使用了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(){