我已经阅读了很多关于打印页码的网站,但是当我尝试打印时,我还是无法显示我的html页面.
所以CSS代码是下一个:
@page {
margin: 10%;
@top-center {
font-family: sans-serif;
font-weight: bold;
font-size: 2em;
content: counter(page);
}
}
Run Code Online (Sandbox Code Playgroud)
我试过把这个页面规则放在里面
@media all {
*CSS code*
}
Run Code Online (Sandbox Code Playgroud)
在它之外,试图把它放进去@media print,但没有任何帮助我在我的页面上显示页码.我试过使用FireFox和Chrome(如你所知,基于WebKit).我认为问题出在我的html或css代码中.
有人能告诉我一个@page在几个页面的大html页面中实现这个规则的例子吗?我只需要html页面的代码和css文件的代码,这是有效的.
PS我有最新支持的浏览器版本.
任何人都可以帮我一个脚本..或一种获得价值的方法
height : 1196px;
width: 284px;
Run Code Online (Sandbox Code Playgroud)
从计算样式表(webkit).我知道IE与往常不同.我无法访问iframe(跨域) - 我只需要高度/宽度.
我需要的屏幕截图(用红色圈出).我如何访问这些属性?

资源
<iframe id="frameId" src="anotherdomain\brsstart.htm">
<html id="brshtml" xmlns="http://www.w3.org/1999/xhtml">
\--I WANT THIS ELEMENTS COMPUTED BROWSER CSS HEIGHT/WIDTH
<head>
<title>Untitled Page</title>
</head>
<body>
BLA BLA BLA STUFF
</body>
</html>
\--- $('#frameId').context.lastChild.currentStyle
*This gets the actual original style set on the other domain which is "auto"
*Now how to getComputed Style?
</iframe>
Run Code Online (Sandbox Code Playgroud)
我得到的最接近的是这个
$('#frameId').context.lastChild.currentStyle
Run Code Online (Sandbox Code Playgroud)
这给了我HTML元素的实际样式,即"auto",这就是iframed文档中的设置.
如何获得所有浏览器用于计算滚动条的计算样式,并检查元素值?
使用Tomalaks回答我为webkit制作了这个可爱的脚本
window.getComputedStyle(document.getElementById("frameId"), null).getPropertyValue("height")
Run Code Online (Sandbox Code Playgroud)
要么
window.getComputedStyle(document.getElementById("frameId"), null).getPropertyCSSValue("height").cssText
Run Code Online (Sandbox Code Playgroud)
结果150px
相同
$('#frameId').height();
Run Code Online (Sandbox Code Playgroud)
所以我让他们在头部添加一个'brshtml'的id-也许它会帮助我更容易地选择元素.Webkit检查现在向我显示html #brshtml但我无法使用它来选择它getelementbyid
一个有趣的用例已经出现在我们面前,我们要求当我们打印一个网站时,打印的副本将有一个页面页眉和页脚,页脚内部有页码.
任何人都知道如何实现这一目标?
注意:浏览器版本可以是最新的,客户端是其他Web开发人员.
所以我知道这个选项:带有CSS/HTML的页码.
到目前为止,似乎是将页码添加到页面的打印版本的最佳方式,但我无法在任何地方获得任何变化.我在Chrome,Firefox和IE9上试过我的Windows 7机器.根据一些链接,看起来像Prince XML这样的更专有的软件可能会支持这种链接.Web浏览器是否支持打印版本?
我试过制作一个空白的html文件,并在头部添加两个样式标签:
@page {
@bottom-right {
content: counter(page) " of " counter(pages);
}
}
Run Code Online (Sandbox Code Playgroud)
我也简化了它,甚至只是content: "TEXT";用来看看我是否可以得到一些东西出现.这是否支持任何地方?通过'this',我特别指的是@page和@bottom-right标签,因为我已经有很多次内容工作了.