What does @-moz-document url-prefix() do?
Any CSS at-rule that starts with @-moz-
is a Gecko-engine-specific rule, not a standard rule. That is, it is a Mozilla-specific extension.
The url-prefix
rule applies the contained style rules to any page whose URL starts with it. When used with no URL argument like @-moz-document url-prefix()
it applies to ALL pages. That's effectively a CSS hack used to only target Gecko (Mozilla Firefox). All other browsers will ignore the styles.
See here for a list of other Mozilla-specific extensions.
what does this mean @-moz-document url-prefix()
The @-moz-document means that the following only applies to Gecko browsers.
the url-prefix()
states that the following only applies when the beginning of the url matches what is passed in the url-prefix()
method.
An example:
url-prefix(http://www.domain.com/page1/)
So the follow css will only apply when that beginning of the page's url begins with http://domain.com/page1/
Unknown @ rule: @-moz-document for Stylish in Firefox 61
Mozilla nuked @-moz-document
rules with Firefox version 61. It's supposed to be replaced with @document
(link), but that doesn't work yet.
This needs to be addressed in Stylish. It would be best if the Import tool parses @-moz-document
rules to its internal metadata and then strips the text on import, IMO.
I couldn't find anything about this new Firefox breakage in a quick search of the Stylish GitHub, so you may want to raise the issue over there.
As a temporary workaround, you can set the layout.css.moz-document.content.enabled
pref to true
in about:config
.
That won't clear the red error X in the edit dialog, but the script will work.
Successor of @-moz-document url-prefix()
In FF V61 release channel and V59 Beta/Dev it was removed, the exception is the url-prefix()
function, so your code should work, here is some info and code:
The
@-moz-document
rule is no longer available from Web content since
it could be used by attackers for CSS injection to steal private data
in the URL of third-party sites. Firefox users are still able to use
this rule in the user stylesheet to personalize their browsing
experience.The at-rule support has already been removed from Nightly and early
Beta/DevEdition as of Firefox 59, and removed from all the channels
with Firefox 61.An exception is the empty url-prefix function that has been used as a
CSS hack targeting Firefox. It continues to be parsed on the Release
channel to avoid breakages but will be removed in the near future once
major compatibility issues are solved
Source
In the current latest version (62.0.3) it still works, as you can see in this fiddle
and using your snippet:
.test{ background-color: red;}
@-moz-document url-prefix() { .test { background-color: blue; }}
<div class="test">test</div>
@-moz-document not working
On the surface it would seem to be because your @-moz-document
appears before the float:none
rule — so it will always get overridden regardless. The presence of a conditional at-rule does not change how the cascade works; this is a common gotcha with @media
rules and applies just as well to @-moz-document
.
You want to move it to the bottom so it will override the previous rule properly in Firefox:
<style>
.attempt {
float:none
}
@-moz-document url-prefix() {
.attempt {
float:left
}
}
</style>
<div class="attempt">someText</div>
How does firefox decide which @-moz-document rules to use?
Well if you have identical attributes in both rules, then the latter are going to overwrite the former because CSS when all thing are considered equal applies rules from top to bottom, so since https://discussions.apple.com/community/ also matches discussions.apple.com the rules from the latter will apply, if you want you can swap the order and this should help.
Related Topics
Without Media Queries How to Achieve 3 Column Desktop to 1 Column Mobile Layout
Google Warning: Resource Interpreted as Font But Transferred with Mime Type Application/Octet-Stream
Is There Any Pros and Cons If I Use Always CSS Class Instead CSS Id for Everything
How to Vertically Center an Image Inside of a Div Element in HTML Using CSS
Background Color of Tabs in Shiny Tabpanel
Css: Using Raw Svg in the Url Parameter of a Background-Image in Ie
How to Make a Fieldset Legend-Style "Background Line" on Heading Text
Difference Between Body and * in CSS
Twitter Bootstrap 3 - Panels of Equal Height in a Fluid Row
How to Make CSS A:Active Work After the Click
How to Change Only the Alpha of a Rgba Background Colour on Hover
How to Render Multiple Columns with Markdown in Github Readme
Set Position Absolute and Margin
Draw Angular Side/Parallelogram Using CSS
Creating a Variable Height "Fixed" Header in CSS with Scrollable Content