-
18 Mar 2010 8:01 AM #1
CSS / Button problem
CSS / Button problem
Hallo,
CSS doesn't work. Whats wrong here?
Thanks,
Michael
TestProject.java
TestProject.cssCode:Button myButton = new Button("button"); // myButton.setWidth("250"); // <-- working! myButton.setStylePrimaryName("myButton"); // not working! myButton.addListener(Events.Select, new Listener<ButtonEvent>() { public void handleEvent(ButtonEvent be) { Window.alert("Registration"); } });
TestProject.htmlCode:.myButton { width: 250px; }
HTML Code:<link type="text/css" rel="stylesheet" href="css/gxt-all.css"> <link type="text/css" rel="stylesheet" href="TestProject.css">
-
18 Mar 2010 9:33 AM #2
How about...
How about...
First, what is the style for? Icon declaration??
I use:
The save-icon is defined in my apps CSS file like:Code:Button saveButton = new Button(); saveButton.setIconStyle("save-icon");
Code:.save-icon { background: url(icons/disk.png) no-repeat center left !important; }
-
18 Mar 2010 2:39 PM #3
I would like to change the width of a button.
By using "myButton.setStylePrimaryName("myButton");" nothing happens.
This is the result when I'm using "myButton.setStyleName("myButton");"

How can I hide the rectangle in the middle of the button?
-
16 May 2010 3:34 AM #4
-
6 Jun 2010 11:02 PM #5
-
13 Jun 2010 4:53 AM #6
I dont' know the solution for you case, but I can suggest an alternative. I normally create icons using AbstractImagePrototype.
Code:import com.google.gwt.user.client.ui.AbstractImagePrototype; import com.google.gwt.user.client.ui.ImageBundle; public interface ExampleImages extends ImageBundle {@Resource("search.jpg") AbstractImagePrototype search();}
And in the application:
However this is not fool-proof, there are some issues when using this with Accordion layout. See http://www.extjs.com/forum/showthrea...476#post476476Code:Button searchButton = new Button(submitLabel, new SubmitButtonListener(formPanel)); searchButton.setIcon(ExampleImages.search()); searchButton.setIconAlign(Style.IconAlign.BOTTOM); formPanel.getButtonBar().add(searchButton);Last edited by questzen; 13 Jun 2010 at 5:24 AM. Reason: Adding known cases of failure
-
15 Jul 2010 5:04 AM #7
I am in the same situation as you. I simply don't know how to set a background image on one button using css. Can anyboidy help us ?
-
15 Jul 2010 5:25 AM #8
Do you want to set the background (change the whole button style) or just add an icon?
-
15 Jul 2010 6:06 AM #9
I want to change the background and also the image that appears when mouse over.
-
15 Jul 2010 6:35 AM #10
I managed to do this by creating a new custom Button widget (extending it) let's say MainMenuButton. And change it's baseStyle to "mainmenu-btn" (or whatever you like).
As a next step you'll have to overwrite all the button css background stuff.Code:public class MainMenuButton extends Button { public MainMenuButton() { baseStyle = "mainmenu-btn"; this.addStyleName(baseStyle); } }
Now set the new css styles you like for your button. For example:Code:.mainmenu-btn .x-btn-ml, .mainmenu-btn .x-btn-mc, .mainmenu-btn .x-btn-mr, .mainmenu-btn .x-btn-tl, .mainmenu-btn .x-btn-tc, .mainmenu-btn .x-btn-tr, .mainmenu-btn .x-btn-bl, .mainmenu-btn .x-btn-bc, .mainmenu-btn .x-btn-br { background-image: none !important; }
For the hover effect:Code:.mainmenu-btn { width: 170px; height: 40px; background-image:url(some/path/bg_menu_btn.png); }
Hope this helps!Code:.mainmenu-btn-over { background-image:url(some/path/bg_menu_btn_hover.png); }
Greets,
oxy


Reply With Quote