appearance (-moz-appearance, -webkit-appearance) - CSS: Cascading Style Sheets 编辑

The appearance CSS property is used to display an element using platform-native styling, based on the operating system's theme. The -moz-appearance and -webkit-appearance properties are non-standard versions of this property, used (respectively) by Gecko (Firefox) and by WebKit-based (e.g., Safari) and Blink-based (e.g., Chrome, Opera) browsers to achieve the same thing. Note that Firefox and Edge also support -webkit-appearance, for compatibility reasons.

The -moz-appearance property was used in XUL stylesheets to design custom widgets with platform-appropriate styling. It was also used in the XBL implementations of the widgets that ship with the Mozilla platform. Starting with Gecko/Firefox 80, these uses were changed to -moz-default-appearance, which should never be used outside of internal stylesheets.

Compatibility note: If you wish to use this property on websites, you should test it very carefully. Although it is supported in most modern browsers, its implementation varies. In older browsers, even the keyword none does not have the same effect on all form elements across different browsers, and some do not support it at all. The differences are smaller in the newest browsers.

Syntax

/* CSS Basic User Interface Module Level 4 values */
appearance: none;
appearance: auto;
appearance: menulist-button;
appearance: textfield;

/* "Compat-auto" values, which have the same effect as 'auto' */
appearance: button;
appearance: searchfield;
appearance: textarea;
appearance: push-button;
appearance: slider-horizontal;
appearance: checkbox;
appearance: radio;
appearance: square-button;
appearance: menulist;
appearance: listbox;
appearance: meter;
appearance: progress-bar;

/* Partial list of available values in Gecko */
-moz-appearance: scrollbarbutton-up;
-moz-appearance: button-bevel;

/* Partial list of available values in WebKit/Blink (as well as Gecko and Edge) */
-webkit-appearance: media-mute-button;
-webkit-appearance: caret;

Values

Standard keywords

ValueDemoBrowserDescription
none
div{ color: black;
-moz-appearance:none;
-webkit-appearance:none;
appearance:none; }
<div>Lorem</div>
Firefox Chrome Safari EdgeNo special styling is applied. This is the default.
auto
div{ color: black;
-moz-appearance: auto;
-webkit-appearance: auto;
appearance:auto; }
<div>Lorem</div>
Firefox ChromeThe user agent selects the appropriate special styling based on the element. Acts as none on elements with no special styling.
menulist-button
div { color: black;
-moz-appearance: menulist-button;
-webkit-appearance: menulist-button; }
<div>Lorem</div>
Firefox Chrome Safari EdgeThe element is styled as a button that would indicate a menulist can be opened.
textfield
div { color: black;
-moz-appearance: textfield;
-webkit-appearance: textfield; }
<div>Lorem</div>
Firefox Chrome Safari Edge
The following values are treated as equivalent to auto:
button
div { color: black;
-moz-appearance: button;
-webkit-appearance: button; }
<div>Lorem</div>
Firefox Chrome Safari EdgeThe element is drawn like a button.
checkbox
div { color: black;
-moz-appearance: checkbox;
-webkit-appearance: checkbox; }
<div>Lorem</div>
Firefox Chrome Safari EdgeThe element is drawn like a checkbox, including only the actual "checkbox" portion.
listbox
div { color: black; height:20px;
-moz-appearance: listbox;
-webkit-appearance: listbox; }
<div>Lorem</div>
Firefox Chrome Safari Edge
menulist
div { color: black;
-moz-appearance: menulist;
-webkit-appearance: menulist; }
<div>Lorem</div>
Firefox Chrome Safari Edge
meter
div{ color: black;
-webkit-appearance: meter; }
<div>Lorem</div>
Chrome Safari Firefox
progress-bar
div{ color: black;
-webkit-appearance: progress-bar; }
<div>Lorem</div>
Chrome Safari Firefox
push-button
div{ color: black; -webkit-appearance: push-button; }
<div>Lorem</div>
Chrome Safari Edge
radio
div { color: black;
-moz-appearance: radio;
-webkit-appearance: radio; }
<div>Lorem</div>
Firefox Chrome Safari EdgeThe element is drawn like a radio button, including only the actual "radio button" portion.
searchfield
div { color: black;
-moz-appearance: searchfield;
-webkit-appearance: searchfield; }
<div>Lorem</div>
Firefox Chrome Safari Edge
slider-horizontal
div{ color: black;
-webkit-appearance: slider-horizontal; }
<div>Lorem</div>
Chrome Safari Edge
square-button
div{ color: black;
-moz-appearance: square-button;
-webkit-appearance: square-button; }
<div>Lorem</div>
Chrome Safari Edge
textarea
div{ color: black;
-webkit-appearance: textarea; }
<div>Lorem</div>
Firefox Chrome Safari Edge

Non-standard keywords

The following values are implemented only for one or both of the prefixed properties, but not on the standard appearance property.

ValueDemoBrowserDescription
attachment
div{ color: black;
-moz-appearance: attachment;
-webkit-appearance: attachment; }
<div>Lorem</div>
Safari
borderless-attachment
div{ color: black;
-moz-appearance: borderless-attachment;
-webkit-appearance: borderless-attachment; }
<div>Lorem</div>
Safari
button-bevel
div { color: black;
-moz-appearance: button-bevel;
-webkit-appearance: button-bevel; }
<div>Lorem</div>
Firefox Chrome Safari Edge
caps-lock-indicator
div{ color: black;
-moz-appearance: caps-lock-indicator;
-webkit-appearance: caps-lock-indicator; }
<div>Lorem</div>
Safari Edge
caret
div { color: black;
-moz-appearance: caret;
-webkit-appearance: caret; }
<div>Lorem</div>
Firefox Chrome Safari Edge
checkbox-container
div { color: black;
-moz-appearance: checkbox-container;
-webkit-appearance: checkbox-container; }
<div>Lorem</div>
FirefoxThe element is drawn like a container for a checkbox, which may include a prelighting background effect under certain platforms. Normally it would contain a label and a checkbox.
checkbox-label
div { color: black;
-moz-appearance: checkbox-label;
-webkit-appearance: checkbox-label; }
<div>Lorem</div>
Firefox
checkmenuitem
div { color: black; height: 20px;
-moz-appearance: checkmenuitem;
-webkit-appearance: checkmenuitem; }
<div>Lorem</div>
Firefox
color-well
div{ color: black;
-moz-appearance: color-well;
-webkit-appearance: color-well; }
<div>Lorem</div>
Safariinput type=color
continuous-capacity-level-indicator
div{ color: black;
-moz-appearance: continuous-capacity-level-indicator;
-webkit-appearance: continuous-capacity-level-indicator; }
<div>Lorem</div>
Safari
default-button
div{ color: black;
-moz-appearance: default-button;
-webkit-appearance: default-button; }
<div>Lorem</div>
Safari Edge
discrete-capacity-level-indicator
div{ color: black;
-moz-appearance: discrete-capacity-level-indicator;
-webkit-appearance: discrete-capacity-level-indicator; }
<div>Lorem</div>
Safari
inner-spin-button
div{ color: black;
-webkit-appearance: inner-spin-button; }
<div>Lorem</div>
Firefox Chrome Safari
image-controls-button
div{ color: black;
-moz-appearance: image-controls-button;
-webkit-appearance: image-controls-button; }
<div>Lorem</div>
Safari
list-button
div{ color: black;
-moz-appearance: list-button;
-webkit-appearance: list-button; }
<div>Lorem</div>
Safaridatalist
listitem
div { color: black;
-moz-appearance: listitem;
-webkit-appearance: listitem; }
<div>Lorem</div>
Firefox Chrome Safari Edge
media-enter-fullscreen-button
div{ color: black;
-webkit-appearance: media-enter-fullscreen-button; }
<div>Lorem</div>
Chrome Safari
media-exit-fullscreen-button
div{ color: black;
-webkit-appearance: media-exit-fullscreen-button; }
<div>Lorem</div>
Chrome Safari
media-fullscreen-volume-slider
div{ color: black;
-moz-appearance: media-fullscreen-volume-slider;
-webkit-appearance: media-fullscreen-volume-slider; }
<div>Lorem</div>
Safari
media-fullscreen-volume-slider-thumb
div{ color: black;
-moz-appearance: media-fullscreen-volume-slider-thumb;
-webkit-appearance: media-fullscreen-volume-slider-thumb; }
<div>Lorem</div>
Safari
media-mute-button
div{ color: black;
-webkit-appearance: media-mute-button; }
<div>Lorem</div>
Chrome Safari Edge
media-play-button
div{ color: black;
-webkit-appearance: media-play-button; }
<div>Lorem</div>
Chrome Safari Edge
media-overlay-play-button
div{ color: black;
-webkit-appearance: media-overlay-play-button; }
<div>Lorem</div>
Chrome Safari
media-return-to-realtime-button
div{ color: black;
-moz-appearance: media-return-to-realtime-button;
-webkit-appearance: media-return-to-realtime-button; }
<div>Lorem</div>
Safari
media-rewind-button
div{ color: black;
-moz-appearance: media-rewind-button;
-webkit-appearance: media-rewind-button; }
<div>Lorem</div>
Safari
media-seek-back-button
div{ color: black;
-moz-appearance: media-seek-back-button;
-webkit-appearance: media-seek-back-button; }
<div>Lorem</div>
Safari Edge
media-seek-forward-button
div{ color: black;
-moz-appearance: media-seek-forward-button;
-webkit-appearance: media-seek-forward-button; }
<div>Lorem</div>
Safari Edge
media-toggle-closed-captions-button
div{ color: black;
-webkit-appearance: media-toggle-closed-captions-button; }
<div>Lorem</div>
Chrome Safari
media-slider
div{ color: black;
-webkit-appearance: media-slider; }
<div>Lorem</div>
Chrome Safari Edge
media-sliderthumb
div{ color: black;
-webkit-appearance: media-sliderthumb; }
<div>Lorem</div>
Chrome Safari Edge
media-volume-slider-container
div{ color: black;
-webkit-appearance: media-volume-slider-container; }
<div>Lorem</div>
Chrome Safari
media-volume-slider-mute-button
div{ color: black;
-moz-appearance: media-volume-slider-mute-button;
-webkit-appearance: media-volume-slider-mute-button; }
<div>Lorem</div>
Safari
media-volume-slider
div{ color: black;
-webkit-appearance: media-volume-slider; }
<div>Lorem</div>
Chrome Safari
media-volume-sliderthumb
div{ color: black;
-webkit-appearance: media-volume-slider-thumb; }
<div>Lorem</div>
Chrome Safari
media-controls-background
div{ color: black;
-webkit-appearance: media-controls-background; }
<div>Lorem</div>
Chrome Safari
media-controls-dark-bar-background
div{ color: black;
-moz-appearance: media-controls-dark-bar-background;
-webkit-appearance: media-controls-dark-bar-background; }
<div>Lorem</div>
Safari
media-controls-fullscreen-background
div{ color: black;
-webkit-appearance: media-controls-fullscreen-background; }
<div>Lorem</div>
Chrome Safari
media-controls-light-bar-background
div{ color: black;
-moz-appearance: media-controls-light-bar-background;
-webkit-appearance: media-controls-light-bar-background; }
<div>Lorem</div>
Safari
media-current-time-display
div{ color: black;
-webkit-appearance: media-current-time-display; }
<div>Lorem</div>
Chrome Safari
media-time-remaining-display
div{ color: black;
-webkit-appearance: media-time-remaining-display; }
<div>Lorem</div>
Chrome Safari
menulist-text
div { color: black;
-moz-appearance: menulist-text;
-webkit-appearance: menulist-text; }
<div>Lorem</div>
Firefox Chrome Safari Edge
menulist-textfield
div { color: black;
-moz-appearance: menulist-textfield;
-webkit-appearance: menulist-textfield; }
<div>Lorem</div>
Firefox Chrome Safari EdgeThe element is styled as the text field for a menulist. (Not implemented for the Windows platform)
meterbar 
div { color: black;
-moz-appearance: meterbar;
-webkit-appearance: meterbar; }
<div>Lorem</div>
FirefoxUse meter instead.
number-input
div { color: black;
-moz-appearance: number-input;
-webkit-appearance: number-input; }
<div>Lorem</div>
Firefox
progress-bar-value
div{ color: black;
-webkit-appearance: progress-bar-value; }
<div>Lorem</div>
Chrome Safari
progressbar
div { color: black;
-moz-appearance: progressbar;
-webkit-appearance: progressbar; }
<div>Lorem</div>
FirefoxThe element is styled like a progress bar. Use progress-bar instead
progressbar-vertical
div { color: transparent;
-moz-appearance: progressbar-vertical;
-webkit-appearance: preogressbar-vertical; }
<div>Lorem</div>
Firefox
range
div { color: black;
-moz-appearance: range;
-webkit-appearance: range; }
range
<div>Lorem</div>
Firefox
range-thumb
div { color: black;
-moz-appearance: range-thumb;
-webkit-appearance: range-thumb; }
<div>Lorem</div>
Firefox
rating-level-indicator
div{ color: black;
-moz-appearance: rating-level-indicator;
-webkit-appearance: rating-level-indicator; }
<div>Lorem</div>
Safari
relevancy-level-indicator
div{ color: black;
-moz-appearance: relevancy-level-indicator;
-webkit-appearance: relevancy-level-indicator; }
<div>Lorem</div>
Safari
scale-horizontal
div { color: transparent;
-moz-appearance: scale-horizontal;
-webkit-appearance: scale-horizontal; }
<div>Lorem</div>
Firefox
scalethumbend
div { color: black;
-moz-appearance: scalethumbend;
-webkit-appearance: scalethumbend; }
<div>Lorem</div>
Firefox
scalethumb-horizontal
div { color: transparent;
-moz-appearance: scalethumb-horizontal;
-webkit-appearance: scalethumb-horizontal; }
<div>Lorem</div>
Firefox
scalethumbstart
div { color: black;
-moz-appearance: scalethumbstart;
-webkit-appearance: scalethumbstart; }
<div>Lorem</div>
Firefox
scalethumbtick
div { color: black;
-moz-appearance: scalethumbtick;
-webkit-appearance: scalethumbtick; }
<div>Lorem</div>
Firefox
scalethumb-vertical
div { color: black;
-moz-appearance: scalethumb-vertical;
-webkit-appearance: scalethumb-vertical; }
<div>Lorem</div>
Firefox
scale-vertical
div { color: transparent;
-moz-appearance: scale-vertical;
-webkit-appearance: scale-vertical; }
<div>Lorem</div>
Firefox
scrollbarthumb-horizontal
div { color: black;
-moz-appearance: scrollbarthumb-horizontal;
-webkit-appearance: scrollbarthumb-horizontal; }
<div>Lorem</div>
Firefox
scrollbarthumb-vertical
div { color: black;
-moz-appearance: scrollbarthumb-vertical;
-webkit-appearance: scrollbarthumb-vertical; }
<div>Lorem</div>
Firefox
scrollbartrack-horizontal
div { color: black;
-moz-appearance: scrollbartrack-horizontal;
-webkit-appearance: scrollbartrack-horizontal; }
<div>Lorem</div>
Firefox
scrollbartrack-vertical
div { color: black;
-moz-appearance: scrollbartrack-vertical;
-webkit-appearance: scrollbarbartrack-vertical; }
<div>Lorem</div>
Firefox
searchfield-decoration
div{ color: black;
-moz-appearance: searchfield-decoration;
-webkit-appearance: searchfield-decoration; }
<div>Lorem</div>
Safari Edge
searchfield-results-decoration
div{ color: black;
-moz-appearance: searchfield-results-decoration;
-webkit-appearance: searchfield-results-decoration; }
<div>Lorem</div>
Chrome Safari Edge(Works on Chrome 51 on Windows 7)
searchfield-results-button
div{ color: black;
-moz-appearance: searchfield-results-button;
-webkit-appearance: searchfield-results-button; }
<div>Lorem</div>
Safari Edge
searchfield-cancel-button
div{ color: black;
-webkit-appearance: searchfield-cancel-button; }
<div>Lorem</div>
Chrome Safari Edge
snapshotted-plugin-overlay
div{ color: black;
-moz-appearance: snapshotted-plugin-overlay;
-webkit-appearance: snapshotted-plugin-overlay; }
<div>Lorem</div>
Safari
sheet
div { color: black;
-moz-appearance: sheet;
-webkit-appearance: sheet; }
<div>Lorem</div>
None
slider-vertical
div{ color: black;
-webkit-appearance: slider-vertical; }
<div>Lorem</div>
Chrome Safari Edge
sliderthumb-horizontal
div{ color: black;
-webkit-appearance: slider-thumb-horizontal; }
<div>Lorem</div>
Chrome Safari Edge
sliderthumb-vertical
div{ color: black;
-webkit-appearance: slider-thumb-vertical; }
<div>Lorem</div>
Chrome Safari Edge
textfield-multiline
div { color: black;
-moz-appearance: textfield-multiline;
-webkit-appearance: textfield-multiline; }
<div>Lorem</div>
FirefoxUse textarea instead.
-apple-pay-button
div{ color: black;
-webkit-appearance: -apple-pay-button; }
<div>Lorem</div>
SafariiOS and macOS only. Available on the web starting in iOS 10.1 and macOS 10.12.1

Obsolete values

The following values were at some point implemented for a prefixed property, but are no longer supported.

ValueBrowserDescription
button-arrow-downFirefoxRemoved in Firefox 64
button-arrow-nextFirefoxRemoved in Firefox 64
button-arrow-previousFirefoxRemoved in Firefox 64
button-arrow-upFirefoxRemoved in Firefox 64
button-focusFirefoxRemoved in Firefox 64
dualbuttonFirefoxRemoved in Firefox 64
groupboxFirefoxRemoved in Firefox 64
menuarrowFirefoxRemoved in Firefox 64
menubarFirefoxRemoved in Firefox 64
menucheckboxFirefoxRemoved in Firefox 64
menuimageFirefoxRemoved in Firefox 64
menuitemFirefoxRemoved in Firefox 64.
menuitemtextFirefoxRemoved in Firefox 64
menupopupFirefoxRemoved in Firefox 64
menuradioFirefoxRemoved in Firefox 64
menuseparatorFirefoxRemoved in Firefox 64
meterchunkFirefoxRemoved in Firefox 64.
progresschunkFirefoxRemoved in Firefox 64.
progresschunk-verticalFirefoxRemoved in Firefox 64.
radio-containerFirefoxRemoved in Firefox 64.
radio-labelFirefoxRemoved in Firefox 64.
radiomenuitemFirefoxRemoved in Firefox 64.
resizerFirefoxRemoved in Firefox 63
resizerpanelFirefoxRemoved in Firefox 63.
scrollbarbutton-downFirefoxRemoved in Firefox 63.
scrollbarbutton-leftFirefoxRemoved in Firefox 63.
scrollbarbutton-rightFirefoxRemoved in Firefox 63.
scrollbarbutton-upFirefoxRemoved in Firefox 63.
separatorFirefoxRemoved in Firefox 64.
spinnerFirefoxRemoved in Firefox 64.
spinner-downbuttonFirefoxRemoved in Firefox 64.
spinner-textfieldFirefoxRemoved in Firefox 64.
spinner-upbuttonFirefoxRemoved in Firefox 64.
splitterFirefoxRemoved in Firefox 64.
statusbarFirefoxRemoved in Firefox 64.
statusbarpanelFirefoxRemoved in Firefox 64.
tabFirefoxRemoved in Firefox 64
tabpanelFirefoxRemoved in Firefox 64.
tabpanelsFirefoxRemoved in Firefox 64
tab-scroll-arrow-backFirefoxRemoved in Firefox 64.
tab-scroll-arrow-forwardFirefoxRemoved in Firefox 64.
toolbarFirefoxRemoved in Firefox 64.
toolbarbuttonFirefoxRemoved in Firefox 64.
toolbarbutton-dropdownFirefoxRemoved in Firefox 64.
toolbargripperFirefoxRemoved in Firefox 64.
toolboxFirefoxRemoved in Firefox 64.
tooltipFirefoxRemoved in Firefox 64.
treeheaderFirefoxRemoved in Firefox 64.
treeheadercellFirefoxRemoved in Firefox 64.
treeheadersortarrowFirefoxRemoved in Firefox 64.
treeitemFirefoxRemoved in Firefox 64.
treelineFirefoxRemoved in Firefox 64.
treetwistyFirefoxRemoved in Firefox 64.
treetwistyopenFirefoxRemoved in Firefox 64.
treeviewFirefoxRemoved in Firefox 64.
-moz-win-borderless-glassFirefoxRemoved in Firefox 64.
-moz-win-browsertabbar-toolboxFirefoxRemoved in Firefox 64.
-moz-win-communicationstextFirefoxRemoved in Firefox 64.
-moz-win-communications-toolboxFirefoxRemoved in Firefox 64.
-moz-win-exclude-glassFirefoxRemoved in Firefox 64.
-moz-win-glassFirefoxRemoved in Firefox 64.
-moz-win-media-toolboxFirefoxRemoved in Firefox 64.
-moz-window-button-boxFirefoxRemoved in Firefox 64.
-moz-window-button-box-maximizedFirefoxRemoved in Firefox 64.
-moz-window-button-closeFirefoxRemoved in Firefox 64.
-moz-window-button-maximizeFirefoxRemoved in Firefox 64.
-moz-window-button-minimizeFirefoxRemoved in Firefox 64.
-moz-window-button-restoreFirefoxRemoved in Firefox 64.
-moz-window-frame-bottomFirefoxRemoved in Firefox 64.
-moz-window-frame-leftFirefoxRemoved in Firefox 64.
-moz-window-frame-rightFirefoxRemoved in Firefox 64.
-moz-window-titlebarFirefoxRemoved in Firefox 64.
-moz-window-titlebar-maximizedFirefoxRemoved in Firefox 64.

Formal definition

Initial valueauto
Applies toall elements
Inheritedno
Computed valueas specified
Animation typediscrete

Formal syntax

none | auto | textfield | menulist-button | <compat-auto>

where
<compat-auto> = searchfield | textarea | push-button | slider-horizontal | checkbox | radio | square-button | menulist | listbox | meter | progress-bar | button

Examples

Make an element look like a menulist button

.exampleone {
  appearance: menulist-button;
}

See also this JSFiddle for an example showing how you might use appearance: none to apply custom styling to radio buttons and checkboxes.

Specifications

SpecificationStatusComment
CSS Basic User Interface Module Level 4
The definition of 'appearance' in that specification.
Working DraftInitial definition.

Browser compatibility

BCD tables only load in the browser

See also

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:237 次

字数:73511

最后编辑:7 年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文