2014-09-16 4 views
5

Mit 0.12.x Version von Compass, ich war die Definition Unterstützung für Oldies auf diese Weise:konfigurieren Kompass-Browser-Unterstützung (Compass 1.x-Syntax)

@import "compass/support" 

$legacy-support-for-ie6: false; 
$legacy-support-for-ie7: true; 
$legacy-support-for-ie8: true; 
$legacy-support-for-mozilla: false; 

@if ($legacy-support-for-ie7) { 
    // specific declaration if ie7 is supported 
} 

Ich bin frage mich, wie ich browser supportCompass 1.x system folgende definieren sollte. Vielleicht so etwas wie folgt aus:

// Add support for a specific browser 
$browser-minimum-versions: (
    'ie': "7", 
    'ie': "8" 
); 

// Reject browsers 
$supported-browsers: reject(browser-versions("ie"), "6", "7", "8"); 

Aber es diesen Fehler zurück (läuft auf Compass 1.0.1):

(Line 206 of /Library/Ruby/Gems/2.0.0/gems/compass-core-1.0.1/stylesheets/compass/_support.scss: 5.5 is not known browser.) 
+0

Welche Browser-Versionen versuchen, Sie zu unterstützen? – cimmanon

+0

In Bezug auf IE,> ie7. –

Antwort

6

Ohne Browser erfolgt durch die $graceful-usage-threshold Größe zu verändern. Wenn Browser X nur 4,99% des Marktanteils hat, möchten Sie ihn auf 5 setzen.

$debug-browser-support: true; 
$browser-minimum-versions: (
    "ie": "9" 
); 
$graceful-usage-threshold: 4.46163; 

@import "compass"; 

.foo { 
    @include opacity(.5); 
    @include border-radius(10px); 
} 

Ausgang:

.foo { 
    /* Content for ie 8 omitted. 
    Minimum support is 9. */ 
    opacity: 0.5; 
    /* Capability border-radius is not prefixed with -moz because 0.25036% of users are affected which is less than the threshold of 4.46163. */ 
    /* Capability border-radius is not prefixed with -ms because 0% of users are affected which is less than the threshold of 4.46163. */ 
    /* Capability border-radius is not prefixed with -o because 0% of users are affected which is less than the threshold of 4.46163. */ 
    /* Capability border-radius is not prefixed with -webkit because 0.1583% of users are affected which is less than the threshold of 4.46163. */ 
    border-radius: 10px; 
} 

Beachten Sie, dass diese andere Minderheit Browsern verursacht ausgeschlossen werden, dass Sie möchten unterstützen. Dann kommt die $browser-minimum-versions ins Spiel.

$browser-minimum-versions: (
    "ie": "9", 
    "safari": "4" 
); 

Ausgang:

.foo { 
    /* Content for ie 8 omitted. 
    Minimum support is 9. */ 
    opacity: 0.5; 
    /* Capability border-radius is not prefixed with -moz because 0.25036% of users are affected which is less than the threshold of 4.46163. */ 
    /* Capability border-radius is not prefixed with -ms because 0% of users are affected which is less than the threshold of 4.46163. */ 
    /* Capability border-radius is not prefixed with -o because 0% of users are affected which is less than the threshold of 4.46163. */ 
    /* Capability border-radius is prefixed with -webkit because safari "4" is required. */ 
    /* Creating new -webkit context. */ 
    -webkit-border-radius: 10px; 
    border-radius: 10px; 
} 

Es gibt Änderungen in den Arbeiten zu erleichtern, alten Browser auszuschließen. Sie folgen können sie hier: https://github.com/Compass/compass/issues/1762

Wenn Sie Regeln für einen bestimmten Browser machen wollen, dann ist die $critical-usage-threshold Variable ins Spiel kommt:

$debug-browser-support: true; 
$browser-minimum-versions: (
    "ie": "9" 
); 
$critical-usage-threshold: 4.46163; 
$graceful-usage-threshold: 4.46163; 

@import "compass"; 

.foo { 
    @include for-legacy-browser('ie', '8') { 
    color: green; 
    // this is based on $critical-usage-threshold by default 
    // if $critical-usage-threshold is lower than the version's usage 
    // then this content will be generated 
    } 
    @if support-legacy-browser('ie', '8') { 
    color: red; 
    } 
} 
+0

https://github.com/Compass/compass/issues/1762 ist die vielversprechendste Sache. – oleq

+0

Danke. Dann nehme ich an, dass "$ graceful-usage-threshold" ein Prozentsatz ist, der auf der [Browser usage table] basiert (http://caniuse.com/usage_table.php) –

+0

Aber dann, was den zweiten Teil meiner Frage betrifft. Wie fügen Sie eine Deklaration für einen bestimmten Browser hinzu, z. B. '@if ($ legacy-support-for-ie7) {// spezifische Deklaration}' –