我可以用独立的样式表显示内部div吗? [英] Can I display an inner div with an independent stylesheet?

查看:67
本文介绍了我可以用独立的样式表显示内部div吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序允许用户编辑文档。毫不奇怪,编辑器小部件将用户文档表示为HTML。



我需要在编辑器外部重新显示文档,但在我的网站布局中。文档需要以与它们在编辑器中呈现的完全相同的样式出现,而不受我网站的样式表影响。我可以在只读模式下使用编辑器,隐藏所有按钮,但我仍然会解决滚动条和边框样式问题。



我已经识别出CSS文件编辑使用。我怎样才能有效地配置一个div元素(包含文档的元素)到(1)忽略所有当前样式,并(2)加载一个css文件以应用到它的内容?



1。)重置包含文档的div的所有样式,并使确保您的文档样式优先于重置。这可能会变得麻烦。



<2>。)使用iframe并在iframe中加载文档和样式。

 < iframe src =... / documents / myDocument.html>< / iframe> 

其中myDocument.html是一个包含文档和样式的html文档(将文档html页面作为任何其他html页面,并确保它有适当的头部和身体标签等。

其他选项:

<

 < a href =... / document /打开文档html页面 myDocument.htmltarget =_ blank>打开文档< / a> 



<2>。)将文档渲染为pdf,并使用pdf查看器将其加载到页面中。 (你会想保留原始文件的备份,因为转换会很糟糕,我猜想)。

My application lets users edit documents. The editor widget, unsurprisingly, represents user documents as HTML.

I need to redisplay the documents outside the editor, but inside my site's layout. Documents need to appear in the exact same style they are presented in the editor, unaffected by my site's stylesheet. I could use the editor in read only mode, with all its buttons hidden, but I still will have scrollbar and border style issues to resolve.

I have identified the CSS file that the editor uses. How can I effectively configure a div element (the one that will contain the document) to (1) disregard all current styling, and (2) load a css file to apply to its content?

解决方案

You have two options:

1.) Reset all styles on the div containing your document, and make sure your document's styles are prioritized over the reset. This could get messy.

2.) Use an iframe and load the document and styles inside the iframe.

<iframe src=".../documents/myDocument.html"></iframe>

Where "myDocument.html" is an html document containing the document and styles (treat the document html page as any other html page, and make sure it has proper head and body tags, etc.

Other options:

1.) Open the document html page inside another window.

<a href=".../document/myDocument.html" target="_blank" >Open Document</a>

2.) Render the document as a pdf, and load it into the page using a pdf viewer. (you would want to keep a backup of the original document, as the conversion back would be terrible, I presume).

这篇关于我可以用独立的样式表显示内部div吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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