mediawiki.ui: checkbox: Correct alignment of long labels
authorBartosz Dziewoński <matma.rex@gmail.com>
Tue, 23 Dec 2014 20:50:03 +0000 (21:50 +0100)
committerBartosz Dziewoński <matma.rex@gmail.com>
Tue, 20 Jan 2015 08:42:27 +0000 (08:42 +0000)
Use display: table-cell; to display the checkbox and the label
side-by-side. I am honestly surprised that this works here. Not sure
if it's a good idea to use… although we successfully did it for
OOjs UI in 2498265b, but we have more control over everything there.

Bug: T85241
Change-Id: I381d05360ad3e7ab153f56772fffb650dab5cda9

resources/src/mediawiki.ui/components/checkbox.less

index 089504a..4829f5f 100644 (file)
@@ -42,7 +42,7 @@
 .client-js .mw-ui-checkbox:not(#noop) {
        // Position relatively so we can make use of absolute pseudo elements
        position: relative;
-       line-height: @checkboxSize;
+       display: table;
 
        * {
                // reset font sizes (see bug 72727)
                max-width: none;
                margin: 0;
                margin-right: 0.4em;
+               display: table-cell;
+
+               & + label {
+                       display: table-cell;
+               }
 
                // the pseudo before element of the label after the checkbox now looks like a checkbox
                & + label::before {
                        border-radius: @borderRadius;
                        width: @checkboxSize;
                        height: @checkboxSize;
+                       line-height: @checkboxSize;
                        background-color: #fff;
                        border: 1px solid @colorGray7;
+                       // align the checkbox to middle of the text
+                       top: 50%;
+                       margin-top: -1em;
                        .background-image-svg('images/checked.svg', 'images/checked.png');
                        .background-size( @checkboxSize - 0.2em, @checkboxSize - 0.2em );
                        background-repeat: no-repeat;