MediaWiki:Mobile.js:修订间差异

无编辑摘要
无编辑摘要
标签移动版编辑 移动版网页编辑
无编辑摘要
标签移动版编辑 移动版网页编辑
 
第117行: 第117行:
         lis.each(function() {
         lis.each(function() {
             var $li = $(this);
             var $li = $(this);
             // 先设置宽度,确保不换行,内容居中
             // 使用 attr 设置 style 属性,确保样式优先级最高
             $li.css({
             var styleStr = 'width: ' + containerWidth + 'px !important; ' +
                'width': containerWidth + 'px',
                          'height: 25px !important; ' +
                'height': '25px',
                          'line-height: 25px !important; ' +
                'line-height': '25px',
                          'list-style: none !important; ' +
                'list-style': 'none',
                          'float: left !important; ' +
                'float': 'left',
                          'display: inline-block !important; ' +
                'display': 'inline-block',
                          'box-sizing: border-box !important; ' +
                'box-sizing': 'border-box',
                          'padding: 0 !important; ' +
                'padding': '0',
                          'margin: 0 !important; ' +
                'margin': '0',
                          'vertical-align: top !important; ' +
                'vertical-align': 'top',
                          'flex-shrink: 0 !important; ' +
                'flex-shrink': '0',
                          'white-space: nowrap !important; ' +
                'white-space': 'nowrap',
                          'overflow: visible !important; ' +
                'overflow': 'visible',
                          'text-overflow: clip !important; ' +
                'text-overflow': 'clip',
                          'text-align: center !important; ' +
                'text-align': 'center',
                          'word-break: keep-all !important; ' +
                'word-break': 'keep-all',
                          'word-wrap: normal !important; ' +
                'word-wrap': 'normal',
                          'max-width: ' + containerWidth + 'px !important; ' +
                'max-width': containerWidth + 'px',
                          'position: relative !important;';
                'position': 'relative'
             $li.attr('style', styleStr);
             });
              
              
             // 确保所有子元素(包括 strong、a、font 等)都不会换行
             // 确保所有子元素(包括 strong、a、font 等)都不会换行
             $li.find('*').css({
             $li.find('*').each(function() {
                 'white-space': 'nowrap',
                 var $elem = $(this);
                'display': 'inline',
                $elem.attr('style',
                'text-align': 'center'
                    'white-space: nowrap !important; ' +
            });
                    'display: inline !important; ' +
           
                    'text-align: center !important;'
            // 特别处理 strong 标签
                );
            $li.find('strong').css({
                'white-space': 'nowrap',
                'display': 'inline'
             });
             });
         });
         });
第230行: 第226行:
             ul.css('width', totalWidth + 'px');
             ul.css('width', totalWidth + 'px');
             lis.each(function() {
             lis.each(function() {
                 $(this).css({
                 var $li = $(this);
                    'width': containerWidth + 'px',
                var styleStr = 'width: ' + containerWidth + 'px !important; ' +
                    'white-space': 'nowrap',
                              'white-space: nowrap !important; ' +
                    'overflow': 'hidden',
                              'overflow: visible !important; ' +
                    'text-overflow': 'ellipsis',
                              'text-overflow: clip !important; ' +
                    'text-align': 'center'
                              'text-align: center !important;';
                 });
                 $li.attr('style', styleStr);
             });
             });