documentcloud / documentcloud-pages

Responsively embed DocumentCloud pages.
https://documentcloud.github.io/documentcloud-pages/examples/
MIT License
23 stars 10 forks source link

Embeds often inherit page styles unintentionally #40

Closed reefdog closed 8 years ago

reefdog commented 8 years ago

One side effect of embedding directly on page (instead of in an iframe) is that we pick up parent page styles. This is fine when intentional, but occasionally picks up things accidentally, like in this clearly oversized example:

toobig

We can't guarantee this, and we don't want to bloat our CSS with too long a selector chain, but I'm going to increase it just a bit to better isolate us from the scary world outside.

knowtheory commented 8 years ago

Yeah i've tried to do this with the viewer as well, and unfortunately there's no way we can fix the specificity issue since targeting with class selectors will always be weaker than element selectors or id selectors:

specificity wars specificity wars

Unless we iframe we will always be at risk of weird markup. That said, it really is nice when any of our embeds pick up nice styling.

reefdog commented 8 years ago

Yup, I don't want to get into an escalating selector arm's race (HOW MANY METAPHORS CAN WE MARSHALL?), just wanting to hit that balance. I think I was being too ginger before. .DC-title as the uppermost selector for our H1 title when H1 styling like .entry-content h1 is suuuper common really needed big brother selector to go to bat for him.