[英]Get the height of a whole page in pixel
對於某些裝飾,我需要在文檔的開頭插入一個上邊距,該上邊距占頁面整個高度的34%(包括邊距)。
我的頁面<body>開始是這樣的:
<body bgcolor="#dedede" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" style="-webkit-text-size-adjust:none;">
<tbody>
<table width="100%" border="0" cellpadding="0" cellspacing="0" align="center" bgcolor="#dedede">
<tr>
<td>
<table class="premier-tableau" width="600" bgcolor="#ffffff" border="0" cellpadding="0" cellspacing="0" align="center">
<thead>
<tr height="500" /> <!-- I need to use this line as a margin -->
</thead>
<tbody>
<tr>
<td width="35" />
<td width="530">
<font color="#5e5e5e" face="Arial, Helvetica, sans-serif" size="2" style="font-size: 12px;">
這是用於電子郵件中。
當然,可以手動計算像素數,並將靜態結果添加到<tr>標記中。 但是,這是半自動化過程的一部分,我想避免這種情況。
另請注意,目標SMTP服務器可能具有嚴格的策略,並拒絕附件。 因此,我看不到如何使用外部庫(例如JQuery)。 隨着現代電子書的發布,我想避免使用它們。
接受任何可嵌入的解決方案(css; javascript; svg ...)。
document.body.parentNode.offsetHeight
但是-javascript不會在電子郵件中運行:)因此,我認為您需要手動執行此操作。
由於您的身體沒有任何邊緣,因此應該使用簡單的身高。
document.getElementsByTagName("body")[0].height
有為此設計的視口單元。 實際上,很少有瀏覽器支持它,但是使用height="34vh"
是幾年后正確的方法。
客戶需要幾年的時間才能遵守該標准。 現在進行的實際方法是每次編輯文檔時手動計算大小(以px為單位)。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.