Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GWT theme style overrides my css style

Tags:

css

themes

gwt

I have some html files with their own css. I want to use them in a gwt application so i copied the html and the css files in the application.

The problem is when i open the html it uses the gwt theme style. For example in my css the html 'body' background color is black, but it looks white unless i deactivate the theme.

How could I override the gwt theme style and use my css styles?

like image 505
david Avatar asked Feb 24 '10 00:02

david


People also ask

What is CSS style overriding?

CSS allows you to apply styles to web pages. More importantly, CSS enables you to do this independent of the HTML that makes up each web page. Overriding: Overriding in CSS means that you are providing any style property to an element for which you have already provided a style.

Does style tag override CSS?

Answer: You cannot override inline CSS if it has ! important . It has higher precedence than the style in your external CSS file. , there's no way to override an inline !

Do inline styles override stylesheets?

Inline styles added to an element (e.g., style="font-weight: bold;" ) always overwrite any normal styles in author stylesheets, and therefore, can be thought of as having the highest specificity.


1 Answers

This post on the GWT mailing list describes an alternative solution. You have to create a new ClientBundle which references your CSS file:

import com.google.gwt.core.client.GWT; import com.google.gwt.resources.client.ClientBundle; import com.google.gwt.resources.client.CssResource;  public interface Resources extends ClientBundle {        public static final Resources INSTANCE = GWT.create(Resources.class);         @Source("style.css")       @CssResource.NotStrict       CssResource css(); } 

And then inside your onModuleLoad() method you have to inject the CSS file:

public class YourApp implements EntryPoint {      public void onModuleLoad() {         //...         Resources.INSTANCE.css().ensureInjected();          //...     } 

In my opinion this is the cleanest and easiest way to override the styles.

like image 129
tsauerwein Avatar answered Oct 18 '22 01:10

tsauerwein