我正在做一個報告,並在報告中,我必須呈現來自不同提供商的電子郵件,這封電子郵件帶有自己的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