1

I've got a jquery plugin which comes with its own stylesheet. However, when I include my own stylesheet along with that of the plugin, the plugin stylesheet always gets affected by the css in my own stylesheet.

Is there a way to prevent this?

3
  • Can you provide some code? What do you mean that plugin comes with a stylesheet? Does it use inline styles? Commented Feb 22, 2011 at 8:16
  • 2
    Include your stylesheet first? Or make sure you're not overdeclaring/creating conflicts. Maybe you can provide your css? Commented Feb 22, 2011 at 8:17
  • it creates conflicts. Say, the links in my style sheetsheet are red, and those in the plugin stylesheet are not declare, it is inheriting the colors. How do i prevent that inheritance? Commented Feb 22, 2011 at 8:22

1 Answer 1

4

There's no quick fix. You either have to resolve conflicting styles by hand, or prefix every style in plugin's CSS with some class name, e.g.

.plugin-x h1 { ... }
.plugin-x li { ... }
.plugin-x .info { ... }

And then wrap HTML element your plugin generates in a div with that special class name:

  <div class="plugin-x"><!-- html generated by the plugin here --></div>

In the case when your own global styles affect the plugin styling, e.g. links become red, you'll have to add this style:

.plugin-x a { color: black }

Or simply edit plugin's stylesheet and specify the color you want.

Sign up to request clarification or add additional context in comments.

1 Comment

Yep, like poster said, there's really no easy fix.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.