CKTIS / CSS
appearance — native, primitive und kompatible Widget-Darstellung
`appearance` bestimmt, ob ein Formular-Widget seine Plattformdarstellung behält oder eine primitive beziehungsweise Basisdarstellung für normales CSS freigibt.
Version: CSS modules; structured CSSWG indexes reconciled with pinned MDN BCD; Chromium 152 scope gate, per-example verification still required
Syntax
none | auto | base | base-select | <compat-auto> | <compat-special>appearance bestimmt, ob ein Formular-Widget seine Plattformdarstellung behält oder eine primitive beziehungsweise Basisdarstellung für normales CSS freigibt.
Drei aktivierte checkbox-Steuerelemente behalten ihren Zustand true/true/true. Natives auto misst 13x13; none ohne Präfix wird zu 24x18 in Rot (rgb(220, 0, 0)), -webkit-appearance mit none zu 26x20 in Blau (rgb(0, 80, 220)).
Syntax: none | auto | base | base-select | <compat-auto> | <compat-special>.
none unterdrückt die native Zeichnung, nicht die Semantik; auto überlässt das Widget Hostsprache und UA. base und base-select beschreiben entstehende Basisdarstellungen, doch CSS UI 4 erklärt base bis zur HTML-Stylesheet-Definition ausdrücklich für nicht auslieferungsreif. <compat-auto> und <compat-special> halten ausgewählte historische Schlüsselwörter kompatibel. Das verlangte -webkit-appearance ist ein Alias des alten Namens von appearance; daraus folgt keine Interoperabilität aller früheren Präfixwerte. Standardnamen bevorzugen, Alias nur für geprüfte Altziele behalten und Fokus- sowie Zustandsanzeige nach eigener Gestaltung wiederherstellen. CSS UI 4 ist ein Working Draft.
Beispiele
document.body.innerHTML =
'<style>input{margin:0}.plain{appearance:auto}.standard{appearance:none;width:24px;height:18px;background:rgb(220,0,0)}.legacy{-webkit-appearance:none;width:26px;height:20px;background:rgb(0,80,220)}</style>' +
'<input class="plain" type="checkbox" checked><input class="standard" type="checkbox" checked><input class="legacy" type="checkbox" checked>';
const controls=[...document.querySelectorAll('input')];
await new Promise(requestAnimationFrame);
const describe=element=>{const style=getComputedStyle(element),box=element.getBoundingClientRect();return style.appearance+'/'+Math.round(box.width)+'x'+Math.round(box.height)+'/'+style.backgroundColor;};
console.log('native='+describe(controls[0])+'; standard='+describe(controls[1])+'; prefixed='+describe(controls[2])+'; checked='+controls.map(control=>control.checked).join('/'));Ergebnis
native=auto/13x13/rgba(0, 0, 0, 0); standard=none/24x18/rgb(220, 0, 0); prefixed=none/26x20/rgb(0, 80, 220); checked=true/true/true
`appearance` bestimmt, ob ein Formular-Widget seine Plattformdarstellung behält oder eine primitive beziehungsweise Basisdarstellung für normales CSS freigibt.