Mani
Mani

Reputation: 293

Conflicts between Custom theme CSS and Liferay CSS

I am trying to customize the Liferay UI by using custom theme using base as as "_Styled" theme.

I have my own css files which I coped to _diff/css folder of theme and imported them "custom.css" file .However its breaking the presentation of liferay.In my custom CSS I have styles defined for all the standard tags like body,div etc which is impacting the liferay UI too.

How can I resolve this conflict? Thanks in advance!

Upvotes: 1

Views: 2603

Answers (3)

Haris
Haris

Reputation: 1141

Ideally if your styles are loaded from custom.css, then will overwrite liferay default styles. In some cases, to overwrite a style in css, you can use !important

for example, liferay default style

body {
   background-color: #fff
}

You can specify your style to consider irrespective of order of loading

body {
   background-color: red !important;
}

Upvotes: 0

Olaf Kock
Olaf Kock

Reputation: 48057

Well, of course it all has an effect on the rest of Liferay as well. Liferay provides quite a bit of the HTML DOM of your page, and if you change the presentation of all of those elements, you'll have to take care to style Liferay's elements too.

Is this a conflict? No. Let's go for the simplest case: You declare div {color:green;}. Of course, now everything, your components as well as Liferay's components, use green text. If you only want to style your own portlets, you might want to specify some portlets: div.portlet-my-own-application {color:green;}

I know that color is a too simple usecase, but I hope it illustrates the solution strategy.

Rather than following Artem Khojoyan's suggestion to override Liferay's base.css, I'd recommend to take a look at the resulting css, what's effective etc., and simplify your own css - adapt it to be used within Liferay - by inspecting the effective CSS for every elements that looks off. Firebug or any of it's relatives are your friend.

I'm afraid, with the details "I'm doing something which has an effect on Liferay UI" there's nothing much more to help you. In fact, I'd hope that what you do has an effect on Liferay's UI... You'll just need to find the proper CSS code

Upvotes: 0

Artem Khojoyan
Artem Khojoyan

Reputation: 857

Quick (and not the best) solution is to remove contents of liferays css file (for example "base.css") and save this empty file in /diff/css/ folder of your theme. This way the base.css will get overriden with your new empty file and thus no styles will get loaded. And your custom.css will be the only stylesheet that is taken into account.

Upvotes: 0

Related Questions