Search code examples
javascriptcssbookmarkletfaultappendchild

Appended control's CSS


I've developed a JavaScript Bookmarklet that have appended div to the current page.

But problem is that, when div and its content loaded because of pages' original CSS codes (Bookmarklet has its own CSS as well), my div's appearance corrupts.

I mean, on every page, some of elements looks different (sometimes labels' heights, sometimes textarea's backgroundcolor, etc.)

Is there a way to correct this fault that you know? It can be a CSS or JavaScript solution.


Solution

  • Is there any way to correct this fault that you know?

    Yes, define every relevant property inside the DIV and !important:

    <div style="width: 300px !important; line-height: 1em !important....">
    

    there is no other perfectly fail-safe way. All external widgets I've seen do it this way.