开发者

Global, CSS independent bar that developers can include on their sites

I am developing a "bar" like what you see on the top of many default Blogger blogs that acts as a unifying element on otherwise different-looking sites. I want to package the code up into a neat package so that I can give other developers a few simple lines of code that they can paste into the beginning of their <body>.

I know there are many ways to do this, like using PHP includes, AJAX calls, JavaScript and XmlHttpRequest, Google closure templates, etc. BUT I want to make sure the开发者_Python百科 bar is CSS independent, meaning other CSS that is used on the site does not affect my bar.

I am wondering what is the best method to accomplish this? Is inline CSS the only way around this?


Just like JavaScript plugin development, there's no guarantee that CSS classes and IDs wont be overridden later.

If the code needs to be inline, I'd suggest namespacing all of your classes and IDs: pluginname-wrapper, pluginname-container, pluginname-block, etc.

Otherwise, you could use an iframe element to store a miniature page.

I'd suggest sticking to namespacing. If someone includes your plugin and it's off by a bit, they'll be able to manually override the styles to make it look the way they want.

Someone who writes div {float:left;} or anything similarly silly will have problems either way, so don't worry about making it the same for everyone, just make it work with the default styles.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜