How to overwrite a style definition?
Asked by hans-peter.geier:

I'm trying to add a space style definition for something which is defined in an atlassian stylesheet.

How can I do it?

e.g. the style sheet "splitter.css" (part of the documentation theme) has

<br />

body, p, td, table, tr, .bodytext, .stepfield, .wiki-content p, .panelContent{  
color: #333;  
background:none;   
}

The "background:none" is causing me some trouble. I found how to create a space style to set background to any other color, but I cannot make this definition uneffective (like "unset" in Linux shell) .


Answers:
author: hans-peter.geier
body: I copied the page and stylesheet to my PC and opened it locally. Modified the stylesheet to no longer enforce the background to "none". In this way I got the row highlighting to work correctly.

Though, this is not a soluation, because I do not want to create my own theme for this purpose, nor do I want to modify the Atlassian provided theme.

So I reported this as a bug.


author: hans-peter.geier
body: I have opened a JIRA issue: ANSWERS-436

though it may be in the wrong queue. Hopefully someone moves it to the appropriate place. (project)


author: David at David Simpson Apps
body: You need to be more aggressive with your CSS selectors.

So this should overide things:

```
body#com-atlassian-confluence, #com-atlassian-confluence p, #com-atlassian-confluence td, #com-atlassian-confluence table, #com-atlassian-confluence tr, #com-atlassian-confluence .bodytext, #com-atlassian-confluence .stepfield, #com-atlassian-confluence .wiki-content p, #com-atlassian-confluence .panelContent {    color: #000;    background: hotpink; }
```

comments: author: hans-peter.geier
body: Thanks, David for our quick answer. Actually, I'm able to set any valid color (even without being "more agressive"), but I cannot remove the effect of the existing "background:none" style definition in splitter.css. There are certain macros (e.g. table-plus from famous Bob Swift) which dynamically set "bgcolor" on tr, but the stylesheet's definition of "background:none" has precendence over html and javascript. Setting background to any color (including "none") turns other attempts to set the bgcolor off. I hacked to comment off the "background:none" line which then had the desired effect, but this is not what I want to do in production.

I just found another question (how-do-i-override-css-styles-in-the-documentation-theme) , where the answer was given to modify or clone the document theme and do what the requestor wanted to do (which is de jure a new theme), but this is not really what I want to do, as I would no longer get Atlassian's support.

I don't know whether there is a way to undefine an existing style attribute?

Maybe I should raise an issue against the Document Theme, if I can't fix this myself?


author: David at David Simpson Apps
body: You won't be able to "unset" just that rule yourself with an override.

The only way of doing it would then be to reapply all the other styles again. This is surely more horrid than hacking the theme jar.

Raising an issue could be the answer. If you hack the Documentation Theme, be sure to increment the version element in the pom.xml, otherwise the changes may not be noticed (because it's a bundled plugin).


Tags: stylesheet