Topic on Extension talk:MobileFrontend

Hiding only from desktop on a Wikimedia wiki

9
NGC 54 (talkcontribs)

How can I hide text only from desktop on a Wikimedia wiki (Romanian Wikipedia)? In other words, that text should be visible only from mobile, but from desktop no. The context is ro:Special:Diff/14156938.

NGC 54 (talkcontribs)

An answer?

Dinoguy1000 (talkcontribs)

You'll have to define a custom CSS class in your wiki's MediaWiki:Common.css file, with display: none;. For my wikis, I've used the class name mobile-show, but given the nomobile class included in the default styles (via Ext:MobileFrontend? I'm not actually sure), a class name such as nodesktop might make more sense/be easier to remember.

NGC 54 (talkcontribs)

@Dinoguy1000: But what is the text that I should add in MediaWiki:Common.css?

Dinoguy1000 (talkcontribs)
.your_class_name {
    display: none;
}

Replace your_class_name with whatever name you decide to use for the class (note that the period before the name is not a mistake; this is what identifies it as a class to your browser).

NGC 54 (talkcontribs)
Dinoguy1000 (talkcontribs)

The CSS page you linked is not being applied to the test page you linked. In order to do that, you need to use Extension:TemplateStyles instead of putting the page name in a class attribute.

NGC 54 (talkcontribs)

@Dinoguy1000: The content is now hidden both from mobile and desktop.

Dinoguy1000 (talkcontribs)

Yes, because your CSS file is being applied both on desktop and mobile. My original advice was based on putting the CSS in your wiki's MediaWiki:Common.css file, since that page is only loaded on desktop. If you instead intend for the CSS to be used via TemplateStyles, you'll have to add extra selectors to prevent it being applied when on mobile; unfortunately, I don't really know how to do this beyond vague ideas.

Reply to "Hiding only from desktop on a Wikimedia wiki"