2011-08-17 18 views
0

我想更改toolbarbutton中菜單按鈕的背景顏色。如何在xul中更改menubutton的背景顏色

我應用了下面的代碼,但它不工作。

<toolbarbutton id="search" background-color="red" type="menu-button" label="Search" width="83" height="25" oncommand="webSearch();event.stopPropagation();"> 
    <menupopup> 
     <menuitem label="Web" value="webs" onclick="webSearch();event.stopPropagation();"/> 
     <menuitem label="Images" value="images" onclick="imageSearch();event.stopPropagation();"/> 
     <menuitem label="News" value="news" onclick="newsSearch();event.stopPropagation();"/> 
     <menuitem label="Video" value="videos" onclick="videoSearch();event.stopPropagation();"/> 
    </menupopup> 
</toolbarbutton> 
+0

我對XUL一無所知,但你的嘗試是明確的*不* CSS。 – 2011-08-17 11:43:19

+0

亞,但可以通過css – gargi 2011-08-17 11:56:24

回答

1

我不認爲你可以有按鈕的背景顏色。請檢查這一點,你可以改變文本的顏色,而不是按鈕的顏色。

我建議你有一個自定義的工具欄按鈕。

https://developer.mozilla.org/en/custom_toolbar_button https://developer.mozilla.org/en/XUL/toolbarbutton

上面的鏈接將幫助您解決您的問題。

<toolbar> 
    <toolbarbutton label="Checkbox Type" type="checkbox" image="firefox.png"/> 
    <toolbarbutton label="Menu Type" type="menu" popup="button-popup" style="font: bold 11px Verdana, sans-serif !important; color:#327DC7; background-color=#327DC7;" /> 
    <toolbarbutton label="Menu Button Type" type="menu-button" popup="button-popup" image="firefox.png"/> 
    <menupopup id="button-popup"> 
    <menuitem label="Item 1"/> 
    <menuitem label="Item 2"/> 
    <menuitem label="Item 3"/> 
    </menupopup> 
</toolbar> 

要了解更多的工具欄菜單按鈕CSS功能,可以檢查你的系統安裝目錄火狐dafult設置。例如,像這樣:

的jar:文件:/// C:/Program%20Files/Mozilla%20Firefox/chrome/classic.jar /skin/classic/global/toolbarbutton.css

3

你應該使用CSS

<toolbarbutton style="background-color: red;">