I have a Flex application with a main class that is a WindowedApplication. The CSS file is loaded using the <fx:Style source="defaults.css"> tag in the MXML.
However, when this main class will open a NativeWindow, the CSS does not get applied. I have a subclass of NativeWindow where I can add some things, but this is ActionScript, not MXML. Is there an equivalent of <fx:Style/> for AS? Or do I have to do things in a different way?
UPDATE:
None of the proposed solutions so far seem to be working. I will try to write a small test app to show the behaviour, maybe it is a bug in the Flex framework.
I think you'll need to load the styles via a compiled stylesheet (as a SWF). You can compile a stylesheet to a SWF with MXMLC (mxmlc stylesheet.css). Then use StyleManager.loadStyleDeclarations(swf) to load and apply the styles.
You might have to do all styling with
someComponent.setStyle("someProperty", "someValue");
There's also a [StyleSheet](You can use StyleSheets parseCSS method class that you could use but it only applies to TextField elements IIRC
Have you tried using global selectors in your CSS?
like
global {
color: #000000;
}
or
s|Button
{
color: #FFFFFF;
skinClass:ClassReference("com.what.skins.ButtonSkin");
}
I have these things in my main application file in a style block and they are applied to all views
Related
I have a Parent.js component with a child component Child.js inside of it.
Parent.js imports parents.css
Child.js imports child.css
If I define this in child.css:
.example {
font-family: 'Roboto', sans-serif;
}
How come I'm able to use this className in the Parent.js component as well despite not specifying it in the parent.css?
Unless you use unique class names, CSS Modules or some other alternatives available for scoping CSS styles to any component in React, styles specified in any CSS file will be applied globally.
If you want to limit styles to any component, use CSS Modules or make sure every class name is unique in your project.
For details on how to use CSS Modules, see Adding a CSS Modules Stylesheet. You can also look at 9 Ways To Implement CSS in React JS for other available alternatives.
I recommend using unique class names. For example, lets say you have multiple ListView components: MemberUsersListView, AdminUsersListView, TestUsersListView; and each of them needs to be styled differently. I would create the following CSS classes:
.MUListView{
...
}
.AUListView{
...
}
.TUListView{
...
}
I know this seem's annoying, but it's cleaner than applying inline styles and easier to implement on smaller projects.
I have a React app that can be included in a page.
My problem is that I don't want to have conflicts between the page's CSS and my React app's CSS.
To prevent my CSS from spilling to the page content, I can simply use a namespace on all my CSS classes, such as "react_app".
But how to prevent external CSS from being used by my react app ? For example the page defines :
body {
font-size: 1em;
line-height: 1.8;
}
How can I make sure that my react components will not pick it up ?
A solution would be to define "line-height" for all my classes to override this definition, but I don't want to do that because it is not possible to cover all properties and it would take space.
Thanks for your help !
Try to use these reset classes inside your component
https://meyerweb.com/eric/tools/css/reset/
Did you try to use CSS-modules ?
https://github.com/gajus/react-css-modules
It might help with your problem.
Just starting using Bulma front end framework, everything is going good until try to use prismjs and start getting conflit with styles because prismjs do not prefix their classes name.
The main problem are with:
.number { ... }
and
.tag {...}
It can be override manually but it is not a good practice. This names are too generic or common to not be prefixed by prismjs.
Is there any way to work around this?
Manually fixed with:
pre code [class~=token]{
font:inherit;
background: inherit;
}
Because "token" class name is from prismjs and appear with other prismjs classes, use this selector to help override the styles needed. Just add this to the custom style and make sure to link after any framework css file linked in the html document.
I have managed to embed my extjs4 panel inside an existing extjs3 application.
I want to inherit the existing css colour schemes for panel headers etc.
But my extjs4 components are 'sandboxed', therefore using the .x4-* namespace for css.
How can:
my-styles.css
.x4-tab { some-stuff }
inherit from:
existing-styles.css
.x-tab { foo: #FFF }
Is this possible? cheers
You can grab all the existing css rules that have '.x-' in the selector and create new rules using '.x4-'.
var newRules = [];
Ext.Object.each(Ext.util.CSS.getRules(), function(selector, rule) {
if (/\.x-/.test(selector)) {
newRules.push(rule.cssText.replace(/\.x-/g, '.x4-');
}
});
Ext.util.CSS.createStyleSheet(newRules.join(' '))
While this is technically possible to do, the results would not actually make sense unless you manually go through each component and override the classes to have the correct css references if they even exist (and you would have to create others manually). This is because Extjs 4 does not work the same way in a technical sense for css namespacing and classes as Extjs 3. You could manually change all the css classes the components are using by overriding their component classes, but this is just not worth the time. What you are trying to do can not be done without a huge amount of effort, and it is just not worth it.
If I am assigning a paricular css class to a control ,it hnherits the class but if i simultaneously give the skin id to the same control then this skin ID overrides the CSS class.
Why this is happening?
Now if I am using !important in the css stylesheets then css class property is inherited by the control.
.lblUserName1
{
width: 400px;
line-height: 32px;
color: Red !important;
font-weight: bold;
background-color: #669999;
}
Please help me...Its creating a heap of confusion..
You should avoid using !important; were you can. Basically it is recommended that you use it only when you are overriding some pre-loaded styles that you can't really change.
ID is basically superior to class. Check the answer marked as correct here: CSS class priorities
Skin probably uses inline CSS in style attribute of your control this way due to CSS herarchy what you define in skin theme will override what you have defined in class which resides external .css file.
Best way to debug CSS and HTML is viewing the code itself.
There is another solution - Use StyelSheetTheme attribute. When applying your theme in the web.config or (page) file as Theme attribute:
<pages Theme="myTheme">
any local cssClass control will be overridden.
However:
<pages StyleSheetTheme="myTheme">
will be secondary meaning the control will keep its assigned cssClass attribute.
So, unfortunately you can't have both (it would have been nice), but you can at least make the theme the secondary choice instead of having the theme override local cssClass settings.