在线文档教程
CSS

-moz-appearance

-moz-appearance

这是一项实验中的技术

由于该技术的规格不稳定,请查看各种浏览器的兼容性表格以供使用。还要注意,随着规范的变化,实验技术的语法和行为在未来版本的浏览器中可能会发生变化。

-moz-appearanceCSS属性在Gecko(Firefox)中使用,以基于操作系统主题的平台本地样式显示元素。

-webkit-appearance属性被基于WebKit(例如Safari)和基于Blink(例如Chrome,Opera)的浏览器用来实现相同的功能。请注意,出于兼容性原因,Edge还支持-webkit-appearance(而不是-ms-appearance)。

/* Partial list of available values in Gecko */ -moz-appearance: none; -moz-appearance: button; -moz-appearance: checkbox; -moz-appearance: scrollbarbutton-up; /* Partial list of available values in WebKit/Blink */ -webkit-appearance: none; -webkit-appearance: button; -webkit-appearance: checkbox; -webkit-appearance: scrollbarbutton-up;

这个属性经常用在XUL的样式表中,用来设计拥有平台原生UI样式的自定义的组件,也用于XBL中,用来实现火狐OS平台的组件。

请不要将这个属性用于网页中:不仅是因为这个属性不是W3C标准, 也是因为这个属性在各个浏览器中的表现不一致。甚至在同一个元素上将这个属性的值设为none,也会在不同浏览器中产生差别。并且一些浏览器也不支持这个属性

初始值none (but this value is overriden in the user agent CSS)
适用元素all elements
是否是继承属性no
适用媒体visual
计算值as specified
动画类型discrete
正规顺序the unique non-ambiguous order defined by the formal grammar

语法

-moz-appearance属性可以被指定为从下面的列表中选择的单个值。

<appearance>是下列关键字之一:

ValueDemoDescription
nonediv {-moz-appearance: none; -webkit-appearance: none; color: black;} <div>Lorem</div> 没有任何特殊样式被应用上,这是默认的值。 但是,有这两个BUG: bug 649849bug 605985
buttondiv {-moz-appearance: button; -webkit-appearance: button; color: black; } <div>Lorem</div> 这个元素将被绘制成按钮样式。
button-arrow-downdiv {-moz-appearance: button-arrow-down; -webkit-appearance: button-arrow-down; color: black; } <div>Lorem</div>
button-arrow-nextdiv {-moz-appearance: button-arrow-next; -webkit-appearance: button-arrow-next; color: black; } <div>Lorem</div>
button-arrow-previousdiv {-moz-appearance: button-arrow-previous; -webkit-appearance: button-arrow-previous; color: black; } <div>Lorem</div>
button-arrow-updiv {-moz-appearance: button-arrow-up; -webkit-appearance: button-arrow-up; color: black; } <div>Lorem</div>
button-beveldiv {-moz-appearance: button-bevel; -webkit-appearance: button-bevel; color: black; } <div>Lorem</div>
button-focusdiv {-moz-appearance: button-focus; -webkit-appearance: button-focus; color: black; } <div>Lorem</div>
caretdiv {-moz-appearance: caret; -webkit-appearance: caret; color: black; } <div>Lorem</div>
checkboxdiv {-moz-appearance: checkbox; -webkit-appearance: checkbox; color: black; } <div>Lorem</div>这个元素将被绘制成复选框样式,仅包括可勾选的那部分。
checkbox-containerdiv {-moz-appearance: checkbox-container; -webkit-appearance: checkbox-container; color: black; } <div>Lorem</div>这个元素将被绘制成复选框容器,并且可在当前平台下形成高亮样式。一般情况下,它会包含一个复选框和一个标签组件。
checkbox-labeldiv {-moz-appearance: checkbox-label; -webkit-appearance: checkbox-label; color: black; } <div>Lorem</div>
checkmenuitemdiv {-moz-appearance: checkmenuitem; -webkit-appearance: checkmenuitem; height: 20px; color: black; } <div>Lorem</div>
dualbuttondiv {-moz-appearance: dualbutton; -webkit-appearance: dualbutton; color: black; } <div>Lorem</div>
groupboxdiv {-moz-appearance: groupbox; -webkit-appearance: groupbox; color: black; } <div>Lorem</div>
listboxdiv {-moz-appearance: listbox; -webkit-appearance: listbox; height:20px; color: black; } <div>Lorem</div>
listitemdiv {-moz-appearance: listitem; -webkit-appearance: listitem; color: black; } <div>Lorem</div>
menuarrowdiv {-moz-appearance: menuarrow; -webkit-appearance: menuarrow; color: black; } <div>Lorem</div>
menubardiv {-moz-appearance: menubar; -webkit-appearance: menubar; color: balck; } <div>Lorem</div>
menucheckboxdiv {-moz-appearance: menucheckbox; -webkit-appearance: menucheckbox; color: black; } <div>Lorem</div>
menuimagediv {-moz-appearance: menuimage; -webkit-appearance: menuimage; color: black; } <div>Lorem</div>
menuitemdiv {-moz-appearance: menuitem; -webkit-appearance: menuitem; color: black; } <div>Lorem</div>这个元素将被绘制成菜单项,鼠标移上去时会有高亮效果。
menuitemtextdiv {-moz-appearance: menuitemtext; -webkit-appearance: menuitemtext; color: black; } <div>Lorem</div>
menulistdiv {-moz-appearance: menulist; -webkit-appearance: menulist; color: black; } <div>Lorem</div>
menulist-buttondiv {-moz-appearance: menulist-button; -webkit-appearance: menulist-button; color: black; } <div>Lorem</div>这个元素将被绘制成带有下拉菜单图标的按钮。
menulist-textdiv {-moz-appearance: menulist-text; -webkit-appearance: menulist-text; color: black; } <div>Lorem</div>
menulist-textfielddiv {-moz-appearance: menulist-textfield; -webkit-appearance: menulist-textfield; color: black; } <div>Lorem</div>这个元素将被绘制成菜单列表中的文本框。(未在Windows平台下实现)
menupopupdiv {-moz-appearance: menupopup; -webkit-appearance: menupopup; color: black; } <div>Lorem</div>
menuradiodiv {-moz-appearance: menuradio; -webkit-appearance: menuradio; color: black; } <div>Lorem</div>
menuseparatordiv {-moz-appearance: menuseparator; -webkit-appearance: menuseparator; color: transparent; } <div>Lorem</div>
meterbardiv {-moz-appearance: meterbar; -webkit-appearance: meterbar; color: black; } <div>Lorem</div>Fx 16 中的新特性
meterchunkdiv {-moz-appearance: meterchunk; -webkit-appearance: meterchunk; color: black; } <div>Lorem</div>Fx 16 中的新特性
progressbardiv {-moz-appearance: progressbar; -webkit-appearance: progressbar; color: black; } <div>Lorem</div>这个元素将被绘制成进度条样式。
progressbar-verticaldiv {-moz-appearance: progressbar-vertical; -webkit-appearance: preogressbar-vertical; color: transparent; } <div>Lorem</div>
progresschunkdiv {-moz-appearance: progresschunk; -webkit-appearance: progresschunk; color: black; } <div>Lorem</div>
progresschunk-verticaldiv {-moz-appearance: progresschunk-vertical; -webkit-appearance: progresschunk-vertical; color: black; } <div>Lorem</div>
radiodiv {-moz-appearance: radio; -webkit-appearance: radio; color: black; } <div>Lorem</div>这个元素将被绘制成单选框样式,仅包括可勾选的那部分。
radio-containerdiv {-moz-appearance: radio-container; -webkit-appearance: radio-container; color: black; } <div>Lorem</div>这个元素将被绘制成单选框容器,并且可在当前平台下形成高亮样式。一般情况下,它会包含一个单选框和一个标签组件。
radio-labeldiv {-moz-appearance: radio-label; -webkit-appearance: radio-label; color: black; } <div>Lorem</div>
radiomenuitemdiv {-moz-appearance: radiomenuitem; -webkit-appearance: radiomenuitem; color: black; } <div>Lorem</div>
rangediv {-moz-appearance: range; -webkit-appearance: radiomenuitem; color: black; } range <div>Lorem</div>
range-thumbdiv {-moz-appearance: range-thumb; -webkit-appearance: range-thumb; color: black; } <div>Lorem</div>
resizerdiv {-moz-appearance: resizer; -webkit-appearance: resizer; color: transparent; } <div>Lorem</div>
resizerpaneldiv {-moz-appearance: resizerpanel; -webkit-appearance: resizerpanel; color: black; } <div>Lorem</div>
scale-horizontaldiv {-moz-appearance: scale-horizontal; -webkit-appearance: scale-horizontal; color: transparent; } <div>Lorem</div>
scalethumbenddiv {-moz-appearance: scalethumbend; -webkit-appearance: scalethumbend; color: black; } <div>Lorem</div>
scalethumb-horizontaldiv {-moz-appearance: scalethumb-horizontal; -webkit-appearance: scalethumb-horizontal; color: transparent; } <div>Lorem</div>
scalethumbstartdiv {-moz-appearance: scalethumbstart; -webkit-appearance: scalethumbstart; color: black; } <div>Lorem</div>
scalethumbtickdiv {-moz-appearance: scalethumbtick; -webkit-appearance: scalethumbtick; color: black; } <div>Lorem</div>
scalethumb-verticaldiv {-moz-appearance: scalethumb-vertical; -webkit-appearance: scalethumb-vertical; color: black; } <div>Lorem</div>
scale-verticaldiv {-moz-appearance: scale-vertical; -webkit-appearance: scale-vertical; color: transparent; } <div>Lorem</div>
scrollbarbutton-downdiv {-moz-appearance: scrollbarbutton-down; -webkit-appearance: scrollbarbutton-down; color: black; } <div>Lorem</div>
scrollbarbutton-leftdiv {-moz-appearance: scrollbarbutton-left; -webkit-appearance: scrollbarbutton-left; color: black; } <div>Lorem</div>
scrollbarbutton-rightdiv {-moz-appearance: scrollbarbutton-right; -webkit-appearance: scrollbarbutton-right; color: black; } <div>Lorem</div>
scrollbarbutton-updiv {-moz-appearance: scrollbarbutton-up; -webkit-appearance: scrollbarbutton-up; color: black; } <div>Lorem</div>
scrollbarthumb-horizontaldiv {-moz-appearance: scrollbarthumb-horizontal; -webkit-appearance: scrollbarthumb-horizontal; color: black; } <div>Lorem</div>
scrollbarthumb-verticaldiv {-moz-appearance: scrollbarthumb-vertical; -webkit-appearance: scrollbarthumb-vertical; color: black; } <div>Lorem</div>
scrollbartrack-horizontaldiv {-moz-appearance: scrollbartrack-horizontal; -webkit-appearance: scrollbartrack-horizontal; color: black; } <div>Lorem</div>
scrollbartrack-verticaldiv {-moz-appearance: scrollbartrack-vertical; -webkit-appearance: scrollbarbartrack-vertical; color: black; } <div>Lorem</div>
searchfielddiv {-moz-appearance: searchfield; -webkit-appearance: searchfield; color: black; } <div>Lorem</div>
separatordiv {-moz-appearance: separator; -webkit-appearance: separator; color: transparent; } <div>Lorem</div>
sheetdiv {-moz-appearance: sheet; -webkit-appearance: sheet; color: black; } <div>Lorem</div>
spinnerdiv {-moz-appearance: spinner; -webkit-appearance: spinner; color: transparent; } <div>Lorem</div>
spinner-downbuttondiv {-moz-appearance: spinner-downbutton; -webkit-appearance: spinner-downbutton; color: black; } <div>Lorem</div>
spinner-textfielddiv {-moz-appearance: spinner-textfield; -webkit-appearance: spinner-textfield; color: black; } <div>Lorem</div>
spinner-upbuttondiv {-moz-appearance: spinner-upbutton; -webkit-appearance: spinner-upbutton; color: black; } <div>Lorem</div>
splitterdiv {-moz-appearance: splitter; -webkit-appearance: splitter; color: transparent; } <div>Lorem</div>
statusbardiv {-moz-appearance: statusbar; -webkit-appearance: statusbar; color: black; } <div>Lorem</div>
statusbarpaneldiv {-moz-appearance: statusbarpanel; -webkit-appearance: statusbarpanel; color: black; } <div>Lorem</div>
tabdiv {-moz-appearance: tab; -webkit-appearance: tab; height: 20px; color: black; } <div>Lorem</div>
tabpaneldiv {-moz-appearance: tabpanel; -webkit-appearance: tabpanel; color: black; } <div>Lorem</div>
tabpanelsdiv {-moz-appearance: tabpanels; -webkit-appearance: tabpanels; color: black; } <div>Lorem</div>
tab-scroll-arrow-backdiv {-moz-appearance: tab-scroll-arrow-back; -webkit-appearance: tab-scroll-arrow-back; color: black; } <div>Lorem</div>
tab-scroll-arrow-forwarddiv {-moz-appearance: tab-scroll-arrow-forward; -webkit-appearance: tab-scroll-arrow-forward; color: black; } <div>Lorem</div>
textfielddiv {-moz-appearance: textfield; -webkit-appearance: textfield; color: black; } <div>Lorem</div>
textfield-multilinediv {-moz-appearance: textfield-multiline; -webkit-appearance: textfield-multiline; color: black; } <div>Lorem</div>
toolbardiv {-moz-appearance: toolbar; -webkit-appearance: toolbar; color: black; } <div>Lorem</div>
toolbarbuttondiv {-moz-appearance: toolbarbutton; -webkit-appearance: toolbarbutton; color: black; } <div>Lorem</div>
toolbarbutton-dropdowndiv {-moz-appearance: toolbarbutton-dropdown; -webkit-appearance: toolbarbutton-dropdown; color: black; } <div>Lorem</div>
toolbargripperdiv {-moz-appearance: toolbargripper; -webkit-appearance: toolbargripper; color: black; } <div>Lorem</div>
toolboxdiv {-moz-appearance: toolbox; -webkit-appearance: toolbox; color: black; } <div>Lorem</div>
tooltipdiv {-moz-appearance: tooltip; -webkit-appearance: tooltip; color: black; } <div>Lorem</div>
treeheaderdiv {-moz-appearance: treeheader; -webkit-appearance: treeheader; color: black; } <div>Lorem</div>
treeheadercelldiv {-moz-appearance: treeheadercell; -webkit-appearance: treeheadercell; height:20px; color: black; } <div>Lorem</div>
treeheadersortarrowdiv {-moz-appearance: treeheadersortarrow; -webkit-appearance: treeheadersortarrow; color: black; } <div>Lorem</div>
treeitemdiv {-moz-appearance: treeitem; -webkit-appearance: treeitem; color: black; } <div>Lorem</div>
treelinediv {-moz-appearance: treeline; -webkit-appearance: treeline; color: black; } <div>Lorem</div>
treetwistydiv {-moz-appearance: treetwisty; -webkit-appearance: treetwisty; color: transparent; } <div>Lorem</div>
treetwistyopendiv {-moz-appearance: treetwistyopen; -webkit-appearance: treetwistyopen; color: transparent; } <div>Lorem</div>
treeviewdiv {-moz-appearance: treeview; -webkit-appearance: treeview; color: black; } <div>Lorem</div>
-moz-win-borderless-glassdiv {-moz-appearance: -moz-win-borderless-glass; color: black; } <div>Lorem</div>仅能在Vista及之后的系统中使用。这个样式将会应用磨砂玻璃样式, -- 但是不含边框 -- 。
-moz-win-browsertabbar-toolboxdiv {-moz-appearance: -moz-win-browsertabbar-toolbox; color: black; } <div>Lorem</div>仅能在Vista及之后的系统中使用。这个工具栏样式主要用于浏览器的标签上。
-moz-win-communicationstextdiv {-moz-appearance: -moz-win-communicationstext; color: black; } <div>Lorem</div>
-moz-win-communications-toolboxdiv {-moz-appearance: -moz-win-communications-toolbox; color: black; } <div>Lorem</div>仅能在Vista及之后的系统中使用。这个工具栏样式主要用于通信和生产应用,对应的前景色是 -moz-win-communicationstext.
-moz-win-exclude-glassdiv {-moz-appearance: -moz-win-exclude-glass; color: black; } <div>Lorem</div>仅能在Vista及之后的系统中使用。这个样式用于取消元素磨砂玻璃效果。
-moz-win-glassdiv {-moz-appearance: -moz-win-glass; color: black; } <div>Lorem</div>仅能在Vista及之后的系统中使用。这个样式用于元素应用磨砂玻璃效果
-moz-win-mediatextdiv {-moz-appearance: -moz-win-mediatext; color: black; } <div>Lorem</div>
-moz-win-media-toolboxdiv {-moz-appearance: -moz-win-media-toolbox; color: black; } <div>Lorem</div>仅能在Vista及之后的系统中使用。这个工具栏样式主要用于管理媒体对象。对应的前景色是 -moz-win-mediatext.
-moz-window-button-boxdiv {-moz-appearance: -moz-window-button-box; color: black; } <div>Lorem</div>
-moz-window-button-box-maximizeddiv {-moz-appearance: -moz-window-button-box-maximized; color: black; } <div>Lorem</div>
-moz-window-button-closediv {-moz-appearance: -moz-window-button-close; color: black; } <div>Lorem</div>
-moz-window-button-maximizediv {-moz-appearance: -moz-window-button-maximize; color: black; } <div>Lorem</div>
-moz-window-button-minimizediv {-moz-appearance: -moz-window-button-minimize; color: black; } <div>Lorem</div>
-moz-window-button-restorediv {-moz-appearance: -moz-window-button-restore; color: black; } <div>Lorem</div>
-moz-window-frame-bottomdiv {-moz-appearance: -moz-window-frame-bottom; color: black; } <div>Lorem</div>
-moz-window-frame-leftdiv {-moz-appearance: -moz-window-frame-left; color: black; } <div>Lorem</div>
-moz-window-frame-rightdiv {-moz-appearance: -moz-window-frame-right; color: black; } <div>Lorem</div>
-moz-window-titlebardiv {-moz-appearance: -moz-window-titlebar; color: black; } <div>Lorem</div>
-moz-window-titlebar-maximizeddiv {-moz-appearance: -moz-window-titlebar-maximized; color: black; } <div>Lorem</div>

正式语法

none | button | button-arrow-down | button-arrow-next | button-arrow-previous | button-arrow-up | button-bevel | button-focus | caret | checkbox | checkbox-container | checkbox-label | checkmenuitem | dualbutton | groupbox | listbox | listitem | menuarrow | menubar | menucheckbox | menuimage | menuitem | menuitemtext | menulist | menulist-button | menulist-text | menulist-textfield | menupopup | menuradio | menuseparator | meterbar | meterchunk | progressbar | progressbar-vertical | progresschunk | progresschunk-vertical | radio | radio-container | radio-label | radiomenuitem | range | range-thumb | resizer | resizerpanel | scale-horizontal | scalethumbend | scalethumb-horizontal | scalethumbstart | scalethumbtick | scalethumb-vertical | scale-vertical | scrollbarbutton-down | scrollbarbutton-left | scrollbarbutton-right | scrollbarbutton-up | scrollbarthumb-horizontal | scrollbarthumb-vertical | scrollbartrack-horizontal | scrollbartrack-vertical | searchfield | separator | sheet | spinner | spinner-downbutton | spinner-textfield | spinner-upbutton | splitter | statusbar | statusbarpanel | tab | tabpanel | tabpanels | tab-scroll-arrow-back | tab-scroll-arrow-forward | textfield | textfield-multiline | toolbar | toolbarbutton | toolbarbutton-dropdown | toolbargripper | toolbox | tooltip | treeheader | treeheadercell | treeheadersortarrow | treeitem | treeline | treetwisty | treetwistyopen | treeview | -moz-mac-unified-toolbar | -moz-win-borderless-glass | -moz-win-browsertabbar-toolbox | -moz-win-communicationstext | -moz-win-communications-toolbox | -moz-win-exclude-glass | -moz-win-glass | -moz-win-mediatext | -moz-win-media-toolbox | -moz-window-button-box | -moz-window-button-box-maximized | -moz-window-button-close | -moz-window-button-maximize | -moz-window-button-minimize | -moz-window-button-restore | -moz-window-frame-bottom | -moz-window-frame-left | -moz-window-frame-right | -moz-window-titlebar | -moz-window-titlebar-maximized

示例

下面将使元素看起来像Firefox中的工具栏按钮:

.exampleone { -moz-appearance: toolbarbutton; }

另见这个JSFiddle的示例,说明如何使用appearance: none将自定义样式应用于单选按钮和复选框。

规范

SpecificationStatusComment
CSS Basic User Interface Module Level 3The definition of 'appearance' in that specification.Candidate RecommendationInitial definition

浏览器兼容性

FeatureChromeEdgeFirefox (Gecko)Internet ExplorerOperaSafari (WebKit)
Basic support1.012-webkit21.0 (1.7 or earlier)-moz1 54 (54)3No support215-webkit3.0-webkit

FeatureAndroidEdgeFirefox Mobile (Gecko)IE PhoneOpera MobileSafari Mobile
Basic support(Yes)(Yes)-webkit(Yes)11.0-webkit2(Yes)(Yes)