@import "mediawiki.mixins"; @import "mediawiki.ui/variables"; // Checkbox // // Styling checkboxes in a way that works cross browser is a tricky problem to solve. // In MediaWiki UI put a checkbox and label inside a mw-ui-checkbox div. // This renders in all browsers except IE6-8 which do not support the :checked selector; // these are kept backwards-compatible using the :not(#noop) selector. // You should give the checkbox and label matching "id" and "for" attributes, respectively. // // Markup: //
// //
//
// //
//
// //
//
// //
// // Styleguide 5. .mw-ui-checkbox { display: inline-block; vertical-align: middle; } @checkboxSize: 1.6em; // We use the not selector to cancel out styling on IE 8 and below .mw-ui-checkbox:not(#noop) { // Position relatively so we can make use of absolute pseudo elements position: relative; line-height: @checkboxSize; * { vertical-align: middle; } input[type="checkbox"] { // we hide the input element as instead we will style the label that follows // we use opacity so that VoiceOver software can still identify it opacity: 0; // ensure the invisible checkbox takes up the required width width: @checkboxSize; height: @checkboxSize; // This is needed for Firefox mobile (See bug 71750 to workaround default Firefox stylesheet) max-width: none; margin-right: .4em; // the pseudo before element of the label after the checkbox now looks like a checkbox & + label { cursor: pointer; &::before { content: ''; position: absolute; left: 0; border-radius: @borderRadius; width: @checkboxSize; height: @checkboxSize; background-color: #fff; border: 1px solid grey; } } // when the input is checked, style the label pseudo before element that followed as a checked checkbox &:checked { + label { &::before { .background-image-svg('images/checked.svg', 'images/checked.png'); .background-size( @checkboxSize, @checkboxSize ); background-repeat: no-repeat; background-position: center top; } } } @focusBottomBorderSize: 0.2em; &:active, &:focus { + label { &::before { box-shadow: inset 0 -@focusBottomBorderSize 0 0 lightgrey; } } } // disabled checked boxes have a gray background &:disabled + label { cursor: default; &::before { background-color: lightgrey; } } } }