注意:此更新如下.我可能会更改描述,因为它不是getComputedStyle问题,实际上是打印媒体的问题,而且Internet Explorer现在支持document.styleSheets [].cssRules这一事实.
我对此感到有些困惑,因为我觉得这很有效,我不确定它最近是否破产了.我正在使用getComputedStyle,我认为它支持所有现代浏览器,但我没有得到IE 11的预期答案.鉴于此代码:
getRealStyle: function(elm, attributes) {
var returnObj = {};
var computed = getComputedStyle(elm);
for(var i=0; i<attributes.length; i++) {
returnObj[attributes[i]] = computed[attributes[i]];
}
return returnObj;
},
Run Code Online (Sandbox Code Playgroud)
其中"attributes"是一个名称数组,我有兴趣获取计算的CSS.它是这样的:
attributes: [
'lineHeight',
'alignmentBaseline',
'backgroundImage', 'backgroundPosition', 'backgroundRepeat', 'backgroundColor',
'baselineShift',
'borderTopWidth','borderTopStyle','borderTopColor',
'borderBottomWidth','borderBottomStyle','borderBottomColor',
'borderLeftWidth','borderLeftStyle','borderLeftColor',
'borderRightWidth','borderRightStyle','borderRightColor',
'borderCollapse',
'clear', 'color',
'display', 'direction', 'dominantBaseline',
'fill', 'float',
'fontStyle', 'fontVariant', 'fontWeight', 'fontSize', 'fontFamily',
'height',
'listStyleType', 'listStyleImage',
'marginTop', 'marginBottom', 'marginLeft', 'marginRight','orphans',
'paddingTop', 'paddingRight', 'paddingBottom', 'paddingLeft',
'pageBreakAfter', 'pageBreakBefore',
'stroke', 'strokeWidth',
'strokeOpacity', 'fillOpacity',
'tableLayout',
'textAlign', 'textAnchor','textDecoration', 'textIndent', 'textTransform', 'textShadow', …Run Code Online (Sandbox Code Playgroud) 我正在使用Morris.js创建图表.我要求将图形导出为pdf.我可以看到图形是svg元素.我该怎么做才能做到这一点.
我有一个XQuery函数将一组XML文件转换为HTML并压缩它们.它在每个文件上运行一个trasform来创建<entry>元素.
从该功能开始:
declare function xport:make-sources( $path as xs:string) as item()* {
for $article in collection(xmldb:encode-uri($path))
let $docnum := $article/article/div[@class = 'content']/@doc/string()
return
<entry name="{concat($docnum,'.html')}" type='text' method='store'>
{transform:transform($article, doc("/db/EIDO/data/edit/xsl/doc-html.xsl"), <parameters/>)}
</entry>
} ;
Run Code Online (Sandbox Code Playgroud)
鉴于输入,我运行XQuery只是向我展示转换的结果......我看到了这一点(正是我所期待的):
<entry name="LS01.html" type="text" method="store">
<html>
<head>
<style>
body {
font-family: Arial;
}
article img {
width:50%;
}
...
Run Code Online (Sandbox Code Playgroud)
您将注意到此条目,并且所有条目都没有XML声明.
但现在让我们把它们放在一起并将这些条目发送到压缩.这都在Web应用程序中.完整的XQuery是这样的:
xquery version "3.0";
import module namespace transform = "http://exist-db.org/xquery/transform";
declare namespace xport = "http://www.xportability.com";
declare function xport:make-sources( $path as xs:string) as item()* {
for $article in collection(xmldb:encode-uri($path)) …Run Code Online (Sandbox Code Playgroud)