|
|||
Mixin in Sass
Hallo,
ich mache gerade meine ersten "Gehversuche" mit Sass. Ich möchte gerne Media-Queries so einsetzen wie in diesem Tutorial: https://davidwalsh.name/write-media-queries-sass Leider ist dieses, wie auch alle anderen welche ich gefunden habe für die Nutzung in scss Dateien bestimmt. Ich habe versucht das ganze in das .sass Format umzusetzen: Code:
// Variables/Media Query $tablet-width: 768px $desktop-width: 1024px @mixin tablet @media (min-width: $tablet-width) and (max-width: $desktop-width - 1px) { @content; } @mixin desktop @media (min-width: $desktop-width) { @content; } Code:
.shop_logo float: left @include tablet float:none Code:
error sass/_custom.sass (Line 35: Mixin "tablet" does not accept a content block.) |
Sponsored Links |
|
||||
Du kannst Dir auf die Schnelle mit Online-Tools wie SassMeister | The Sass Playground! behelfen. Wenn Du dort Dein scss Beispiel einfügst und dann im Menü options > Syntax Sass auswählst erhälst Du Deine gewünschte syntax.
Code:
$tablet-width: 768px $desktop-width: 1024px =tablet @media (min-width: #{$tablet-width}) and (max-width: #{$desktop-width - 1px}) @content =desktop @media (min-width: #{$desktop-width}) @content |
Sponsored Links |
|
|||
Vielen Dank für deine Antwort.
Ich habe das ganze jetzt mal ausprobiert, bekomme aber leider folgende Fehlermeldung: Code:
(Line 38: Illegal nesting: Only properties may be nested beneath properties.) Code:
@media (min-width: $tablet-width) and (max-width: $desktop-width - 1px) |
|
|||
Die Zeile stammt aus der Datei in der die Mixins deklariert werden. Hier mal der komplette Inhalt.
Code:
// Mixins // ------ // Mixins allow you to define styles that can be re-used // throughout the stylesheet without needing to resort to // non-semantic classes like .float-left. Mixins can also // contain full CSS rules, and anything else allowed // elsewhere in a Sass document. They can even take // arguments which allows you to produce a wide variety // of styles with very few mixins. // // For complete documentation: // Sass mixins: http://sass-lang.com/docs/yardoc/file.SASS_REFERENCE.html#mixins // Bourbon mixins: http://bourbon.io/docs/ // Import variables for use in Mixins. @import _variables.sass // Rounded corners mixin. @mixin border-radius($top: 10px, $right: $top, $bottom: $top, $left: $right) border-radius: $top $right $bottom $left -moz-border-radius: $top $right $bottom $left -webkit-border-top-left-radius: $top -webkit-border-top-right-radius: $right -webkit-border-bottom-right-radius: $bottom -webkit-border-bottom-left-radius: $left @mixin grid-column width: 22% margin: 1% float: left // Variables/Media Query $tablet-width: 768px $desktop-width: 1024px =tablet @media (min-width: $tablet-width) and (max-width: $desktop-width - 1px) @content =desktop @media (min-width: $desktop-width) @content |
|
|||
An der Einrückung lag es auch nicht.
Aber wahrscheinlich hast du recht, wenn du sagst das es mehr Sinn macht mit scss zu arbeiten. Ich habe jetzt alle Dateien konvertiert und nun keine Probleme mehr . Vielen Dank für deine Hilfe |
|
||||
Klammern retten Leben. Auch beachten sollte man evtl die genutzte SASS Version.
__________________
Hier ein immer gültiges Statement: Überarbeite deine Code, lerne die Grundlagen, widersprich mir nicht, wehre dich nicht, ich habe Recht, wir sind Lolgion, wir sind viele.. potato... All meine Angaben sind ohne Gewähr, es könnte also trotz meiner Unfehlbarkeit dazu kommen dass ich falsch liege www.richard-thiel.de | Müssen Websiten überall gleich ausschauen? |
|
|