以像素为单位获取整个页面的高度 [英] Get the height of a whole page in pixel

查看:103
本文介绍了以像素为单位获取整个页面的高度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于某些装饰,我需要在文档的开头插入一个上边距,代表整个页面高度的34%(包含边距)。

我的页面< body>>像这样开始:

 < body bgcolor =#dededeleftmargin =0topmargin =0marginwidth =0marginheight =0style = -  webkit-text-size-adjust:none;> 
< tbody>
< table width =100%border =0cellpadding =0cellspacing =0align =centerbgcolor =#dedede>
< tr>
< td>
< table class =premier-tableauwidth =600bgcolor =#ffffffborder =0cellpadding =0cellspacing =0align =center>
< thead>
< tr height =500/> <! - 我需要将此线用作边距 - >
< / thead>
< tbody>
< tr>
< td width =35/>
< td width =530>

这是用于在电子邮件中使用的。



当然,可以手动计算像素的数量,并将静态结果添加到< tr>标签。但是,它是半自动过程的一部分,我想避免这种情况。

另请注意,目标SMTP服务器可能有严格的策略并拒绝附件。所以,我看不到如何使用外部库(如JQuery)。作为一个现代的ecmascript可用,我想避免使用它们......



任何可嵌入的解决方案(css; javascript; svg ...) p>

解决方案

有一些专门为此设计的视口单元。很少有浏览器支持它,但使用 height =34vh将是几年前正确的方式。



<客户要遵守标准需要几年的时间。现在进行的一种实际方法是每次编辑文档时手动计算大小(以像素为单位)。


For some decoration, I need to insert an upper margin at the beginning of the document which represent 34% of the whole height of the page (margin included).
My page < body> start like this:

    <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;">

This is for using in e-mails.

Of course it is possible to calculate manually the number of pixel, and add the static result to the < tr> tag. But, It is part of a semi-automated process, and I would like to avoid that.
Also note that the destination SMTP server may have a strict policy and refuse attachments. So, I don't see how to use externals libraries (such as JQuery). As a modern ecmascript is available, I would like to avoid using them...

Any embeddable solutions (css;javascript;svg ...) are accepted.

解决方案

There is the viewports Units which have been designed for that. Few browser support it actually, but using height="34vh" will be the right way to proceed in some years.

It will take some years for clients to comply with the standard. An actual way to proceed now, is to compute the size (in px) manually each time the document is edited.

这篇关于以像素为单位获取整个页面的高度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆