views:

29

answers:

3

I am developing a Google Chrome extension.

Extension shows a dialog box (jquery ui, as a div) inside any webpage, in the dialog box user can add some content [HTML content without body, without styles info].

The problem i am facing is, that the styles specified in the webpage are getting applied to the jquery dialog and the content user is adding.

For ex. when i launch my plugin on stackoverflow webpage, all text become center aligned, etc etc.

What is the best way to get rid of parent styles inside a div?

A: 

I've done that using an IFRAME, which basically creates a whole new html document inside a box, without the styles from the "parent" page. The other option is to redefine all the styles in your div, but that's very tedious and ugly.

cambraca
Thanks, i will give it a try :)
gaurav
+1  A: 

you should look into the reset stylesheets almost every CSS framework comes with. You can take that reset stylesheet and apply all of the reset styles to your specific DIV:

div.YourDiv, div.YourDiv * {
   margin:0;
   padding:0;
   border:0;
   ...
}

which should reset both YourDiv and all elements below. After that, you can get started w/ styling the sub elements as you see fit.

Anatoly G
Wouldn't it also reset all styles on a parent page?
serg
no, as the style above only resets the specific div YourDiv and all elements that are descendants of this div. Unless there is a div on that page that has the class YourDiv, you should be all set.
Anatoly G
I see, good idea.
serg
The problem is i do not know what html content user will set inside the div [in this case defining a reset css looks impossible :(]
gaurav
Reset doesn't reset User's content, it resets the default stylesheet of the browser. Read here for more info: http://meyerweb.com/eric/tools/css/reset/
Anatoly G
A: 

I am also facing same problem, I will try and let you know.

shilpa