我正在做一个报告,并在报告中,我必须呈现来自不同提供商的电子邮件,这封电子邮件带有自己的css(通常是内联css,但有时他们适用一般样式)。我通常使用iframe来封装css,所以它不会打破我的,但我现在不能使用它。封装css
有没有一种方法来封装css而不使用iframes?
这里是我遇到的问题的一个例子:
<html>
<head>
<style>
// I enclose it to content so it doesn't override the email css
#my_content table, #my_content p {
color: black;
}
</style>
</head>
<body>
<div id='my_content'>
... some stuff ...
<div id='email'>
<html>
<head>
<style>
table {
margin-left: 100cm; // screws up all my tables
}
.... some styles that should only apply inside the email div ...
</style>
</head>
<body>
.... email content ...
</body>
</html>
</div>
</div>
</body>
</html>
我可以提取HTML结构和刚刚得到什么的对身体,但再不是所有我的电子邮件会看,因为它应该。此外,该HTML必须是有效的,所以任何建议将是伟大的!
所以你不使用类? – ChaosPandion
是的!使用'scoped'属性。然而,我不相信它支持任何地方。 (好吧,你可以在Chrome浏览器中用'chrome:// flags'打开它。) – Ryan
我确实使用了类,让我在问题中更好地解释电子邮件如何破坏我的css – Hassek