I have a general question regarding styles. I have a couple of text fields I want to customize in terms of style. So this works like that in a template element:
To avoid changing multiple elements, when for instance I want to change to color, I wanted to move that style to a central definition and refer it. Therefor a have added a a template (to the head section) and added the following:
But both doesn't work. I am no html expert, can somebody give me a hint how to define such a central style correctly and refer it in a generic element?
This is not valid (only style attributes go in the style tag)
This is correct
Likely due to specificity. There are already styles applied to all dashboard elements (provided by the dashboard) however your elements class selector .custom_group_section is probably less specific than the built in styles dashboard provides.
IMPORTANT My example (.widget > div > div p.custom_group_section) selector above is completely made up. You will need to inspect the thing you are trying to style to determine a valid selector
Essentially, you need to read up a bit on CSS selectors and specificity
If you want to check a selector works, put it in the browsers console like this $('div > p.my-selector') and you will instantly see if it selects the things you are wanting to be targeted by your CSS.
thanks for the quick reply. I have seen that only some of the styles are applied when using my original global style definition. I tried your style definition, but it doesn't work.
I want to use my
styles only on first level stage inside a group.
I will read your recommended links and more about CSS selectors. That way I hope to get it working.
This selector is extremely specific in that it will only EVER target a p element inside the 19th md-card inside an element explicitly named #Erdgeschoss_Zimmer_Benno_cards
I did explain this before...
And why i said...
Look at the source HTML of your element. Look at the defining features of its parent and parents parents. Devise a selector that will be specific but also flexible enough to be re-used on other elements you apply your class to.
As a hack, you could simply force it to work (you may not realise for some time why it is a hack, but trust me here (or read up on why !important it is bad)
Not forgetting that your browser dev tools are made for this kind of issue.
Open up the elements tab, select the P tag you are interested in and look at the Styles panel, it shows you what styles might apply, where they come from and which have been overridden (they are crossed out).
You can also look at the "Computed" panel and get a different view.