Page MenuHomePhabricator

Media queries not respected in skins
Closed, InvalidPublic

Description

Author: m33tar

Description:
Media queries are ignored when included in a skin's css file and loaded through load.php.

To test: add a style declaration in a media query to a skin's screen.css:

@media screen {

body {background-color: orange;}

}

The only browser I've found where the style is respected in Firefox 14.0.1, on Mac and PC.

Media queries function as expected when added to MediaWiki:Common.css.

If the css file is added directly to the header with a <style> tag, media queries function as expected.


Version: 1.18.x
Severity: minor

Details

Reference
bz38586

Event Timeline

bzimport raised the priority of this task from to Needs Triage.Nov 22 2014, 12:55 AM
bzimport set Reference to bz38586.
bzimport added a subscriber: Unknown Object (MLST).

Your skin resource definition probably looks something like:

'skins.vector' => array(
'styles' => array(

		'common/commonElements.css' => array( 'media' => 'screen' ),
		'common/commonContent.css' => array( 'media' => 'screen' ),
		'common/commonInterface.css' => array( 'media' => 'screen' ),
		'vector/screen.css' => array( 'media' => 'screen' ),

),
'scripts' => 'vector/vector.js',
'remoteBasePath' => $GLOBALS['wgStylePath'],
'localBasePath' => $GLOBALS['wgStyleDirectory'],
),

As you can see, each file is already assigned a media type. Trying to use @media blocks in those files will result in nested @media blocks, so obviously that doesn't work. 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.

m33tar wrote:

Understood, thank you.

Paladox subscribed.

Is this resolved or does this still occur.