Reputation: 1816
I have a page from which I call fancybox which contains some html template (something like an email template). The problem is that all CSS from the main page affects the content in the fancybox and vice versa. What I would like is to isolate them somehow, so that their CSSs don't affect each other.
Example: I have background image set for h3 for the main page. Also, in fancybox I have h3 element which has no CSS assigned to it, but it pulls the style from the main page and gets the same background image (which shouldn't happen).
Is this somehow possible?
Upvotes: 2
Views: 2596
Reputation: 72222
You have 3 options really.
h3 {...}
use #wrapper h3 {...}
Upvotes: 1
Reputation: 1841
You could split your CSS into multiple files, only pulling in what you need to for each html. If you aren't able to do that you can give the body a specific #id
for your template that gets loaded into the fancybox.
<body id="fancy_content">
and then adapt your styles for that template
body#fancy_content h3 {
color: green;
}
You may still end up with a bit of style clash if you leave it in one file but this will give you a method to go on to get it working.
Upvotes: 3
Reputation: 509
try adding IDs to your html elements then use CSS IDs
h3#idname { color: #FF0000; }
Upvotes: 0