| Page 1 of 1 | [ 7 posts ] |
|
I am dynamically loading a css page after a user logs in.
But I can not figure out how to load and and override the defualt yui css. I have read about insertBefore but I can not get it to work. I have <style id="styleoverrides" type="text/css"></style> as the first item in the body then in my js i call. var options = { insertBefore: 'styleoverrides' }; Y.Get.css(data.css, options); - data.css contains my css file name i am trying to override an accordion node object that is created a little later in the script. How do i do this? |
|
What you have to do is make sure that you inject your CSS after where YUI injects it.
I would suggest doing this: * Create a `yui-inject` element in head and set your YUI config to `insertBefore` that element. * Create your `styleoverrides` element after that in the DOM. * Then when using `Y.Get.css` with the overrides you can be certain that your css is always after YUI's injected CSS. Make sense? |
|
Yes and No
I understand what we are trying to do, but exactly the way is alluding me. I have <link id="yuiinject" /> before any css links in the head ( i tried it after as well) I have <style id="styleoverrides" type="text/css"></style> after my head closes and before the body My script YUI({ insertBefore: 'yuiinject', ... }).use( ... and my get.css - called after a io calls and stuff var options = { insertBefore: 'styleoverrides' }; Y.Get.css(data.css, options); I can look in firebug and see where my css is overridden by the yui css classes What am I missing? |
|
Can you post an example to jsfiddle.net so I can see it? That config looks right, but your override CSS might not be specific enough to overwrite the YUI CSS.
|
|
Ok here is the link on jsFiddle
http://jsfiddle.net/EKFZW/ I don't know how well it translates since i am loading the css on the fly On my side the padding of 0px is being overridden by the yui3 padding of 5px |
|
From your simple example, it looks like your extra CSS is not specific enough.
You are using: Code: .yui3-accordion-item-hd { //Rules } When you should be using: Code: .yui3-skin-sam .yui3-accordion .yui3-accordion-item .yui3-accordion-item-hd { //Rules } You need to be at a greater specificity than the original rule to override it. |
|
that did it thanks!
|
| Page 1 of 1 | [ 7 posts ] |
| You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum |
© 2006-2013 Yahoo! Inc. All rights reserved.
All code on this site is licensed under the BSD License unless stated otherwise.
About This Site · Security Contact Info
Powered by phpBB® Forum Software © phpBB Group