<link href="/css/style.css" rel="stylesheet"> <style> body{background:#fff;margin:0px;} .print{background:#fff;padding-left:8px;} .edit-con{box-sizing:border-box;top:6px;} .layui-btn{ display: inline-block; height: 38px; line-height: 38px; padding: 0 18px; background-color: #009688; color: #fff; white-space: nowrap; text-align: center; font-size: 14px; border: none; border-radius: 2px; cursor: pointer; } </style> @foreach($html as $item) <div class="print"> {!! $item !!} </div> </div> @endforeach <script src="../../../../js/jquery-2.2.1.js"></script> <script type="text/javascript"> $(function(){ $(".print").width($(".edit-con").width()); if($(".edit-con").height()==280){ $(".print").css({"height":"303px"}) } $(".huabuitem[type='5'],.huabuitem[type='6'],.huabuitem[type='7']").each(function(){ var urlo_=$(this).css("backgroundImage").replace('url(','').replace(')',''); $(this).css({"background":""}) $(this).html("<img src='"+urlo_.substring(1,urlo_.length-1)+"' />"); if($(this).attr("name")=="yiweimait"){ var max_width=$(this).width(); var width_=$(this).find("img").width(); if(width_>max_width){ width_=max_width } $(this).find("img").css({height:"100%",width:width_}); }else{ $(this).find("img").css({width:"100%",height:"100%"}) } }) setTimeout(function(){ window.print(); }, 100); }) </script>