Do Media Queries work in MediaWiki?

一曲冷凌霜 提交于 2019-12-04 08:58:28

There are a couple of ways to do it besides adding the queries to Common.css. Both ways involve bypassing the style preprocessing of MediaWiki's Resource Loader, new as of version 1.17.

Method 1:

According to this thread:

To load a single css file (raw, without minification and other ResourceLoader processing): Use OutputPage::addStyle( url, media, condition ) where url points to a file directly. For example:

$out->addStyle( 'modules/IE70Fixes.css', 'screen', 'IE 7' );

So add this line to the /skins/customskin.php file, in the initPage() function:

$out->addStyle( 'customskin/customstyle.css', 'screen');

Method 2:

According to a response from a MediaWiki developer to this bug I filed:

If you're in a skin and you want something to apply to a specific media type, put it in a separate file and declare the media type in the resource definition. Either that or omit the media type in the resource definition and you'll be able to use @media blocks.

So, in resources/resources.php, in the skin's array constructor, replace this line:

'styles' => array( 'customskin/customstyle.css' => array( 'media' => 'screen' ) ),

With this line:

'styles' => array( 'customskin/customstyle.css' ),
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!