HTML 페이지에 두 개의 표가 있습니다. 하나는 화면에 표시되고 다른 하나는 CSS를 사용하여 숨겨집니다. 숨겨진 테이블을 인쇄하고 싶습니다.숨겨진 테이블을 HTML로 인쇄하는 방법은 무엇입니까?
어떻게하면됩니까?
HTML 페이지에 두 개의 표가 있습니다. 하나는 화면에 표시되고 다른 하나는 CSS를 사용하여 숨겨집니다. 숨겨진 테이블을 인쇄하고 싶습니다.숨겨진 테이블을 HTML로 인쇄하는 방법은 무엇입니까?
어떻게하면됩니까?
print.css 스타일 시트를 만들고 거기에 표시되도록 테이블을 설정하십시오. 추가, 다음
<link rel="stylesheet" media="print" href="/path/to/print.css" type="text/css" />
및 print.css
내부 : 테이블을 인쇄 할 페이지
, 추가
<link rel="stylesheet" href="print.css" type="text/css" media="print" />
display
특성 table
에 인쇄 스타일 시트를 추가하고 설정
table {
display: table;
visibility: visible;
}
시험해보기 :
<a href="javascript:void(0);" id="printPage">Print</a>
<table id="tblprint" style="visibility:hidden;">
<tr>
<td>Print Data</td>
</tr>
</table>
<script lang='javascript'>
$(document).ready(function(){
$('#printPage').click(function(){
var data = '<input type="button" value="Print this page" onClick="window.print()">';
data += '<div id="div_print">';
data += $('#tblprint').html();
data += '</div>';
myWindow=window.open('','','width=200,height=100');
myWindow.innerWidth = screen.width;
myWindow.innerHeight = screen.height;
myWindow.screenX = 0;
myWindow.screenY = 0;
myWindow.document.write(data);
myWindow.focus();
});
});
</script>
외부 CSS를 사용하고 싶지 않습니다. 인라인 CSS를 사용하여 숨겨진 테이블을 인쇄하는 방법이 있습니까? – Ganesh
아니요. CSS를 인라인하는 것은 주된 측면에서 실제로 나쁜 습관입니다. 왜 당신은 외부 CSS를 사용하고 싶지 않아? – BenM
외부 CSS에서 수행 할 수 있다면 인라인으로도 해당 기능을 지원한다고 생각합니다. 그리고 난 단지 2 페이지와 함께 1 페이지를 가지고 있고이 파일 (HTML 파일)을 사용 하여이 인쇄를 완료해야합니다. – Ganesh