Share
Embed
Sass Why for the CSS Guy
An intro to Sass and Compass for CSS fans. From @Beau Smith, front end tech lead at @Square.
Previously posted to: http://www.slideshare.net/beausmith/sass-why-for-the-css-guy-9475297
Beau Smith
April 06, 2012
Transcript
316 slides
-
Sass Why for the CSS Guy An intro to Sass
for CSS fans -
• CSS meta-language • Simpler, more elegant syntax for CSS
• Helps to create manageable stylesheets Sass -
• CSS meta-language • Simpler, more elegant syntax for CSS
• Helps to create manageable stylesheets • An upgrade to CSS Sass -
• CSS meta-language • Simpler, more elegant syntax for CSS
• Helps to create manageable stylesheets • An upgrade to CSS Sass makes CSS fun again. Sass -
• CSS meta-language • Simpler, more elegant syntax for CSS
• Helps to create manageable stylesheets • An upgrade to CSS Sass makes CSS fun again. Sass Two delicious flavors Sass & SCSS -
• CSS authoring framework built in Sass • Collection of
Sass mixins and functions -
• CSS authoring framework built in Sass • Collection of
Sass mixins and functions • Library of the web’s most reusable CSS patterns -
• CSS authoring framework built in Sass • Collection of
Sass mixins and functions • Library of the web’s most reusable CSS patterns • Makes CSS3 easy -
• both functionally equivalent • both support the same feature
set Sass and SCSS Two delicous flavors… -
• both functionally equivalent • both support the same feature
set • neither will be deprecated Sass and SCSS Two delicous flavors… -
• both functionally equivalent • both support the same feature
set • neither will be deprecated • SCSS is not a successor to Sass Sass and SCSS Two delicous flavors… -
• both functionally equivalent • both support the same feature
set • neither will be deprecated • SCSS is not a successor to Sass • each make different people happy Sass and SCSS Two delicous flavors… -
• both functionally equivalent • both support the same feature
set • neither will be deprecated • SCSS is not a successor to Sass • each make different people happy • some people like both Sass and SCSS Two delicous flavors… -
CSS nav { background: #ccc; width: 500px; margin: 10px auto;
} nav a { float: left; padding: 0 5px; color: #666; } nav a:hover { color: #000; } -
CSS SCSS nav { background: #ccc; width: 500px; margin: 10px
auto; a { float: left; padding: 0 5px; color: #666; &:hover { color: #000; } } } nav { background: #ccc; width: 500px; margin: 10px auto; } nav a { float: left; padding: 0 5px; color: #666; } nav a:hover { color: #000; } -
CSS SCSS nesting nav { background: #ccc; width: 500px; margin:
10px auto; a { float: left; padding: 0 5px; color: #666; &:hover { color: #000; } } } nav { background: #ccc; width: 500px; margin: 10px auto; } nav a { float: left; padding: 0 5px; color: #666; } nav a:hover { color: #000; } -
CSS SCSS nesting nav { background: #ccc; width: 500px; margin:
10px auto; a { float: left; padding: 0 5px; color: #666; &:hover { color: #000; } } } nav { background: #ccc; width: 500px; margin: 10px auto; } nav a { float: left; padding: 0 5px; color: #666; } nav a:hover { color: #000; } -
CSS SCSS nesting nav { background: #ccc; width: 500px; margin:
10px auto; a { float: left; padding: 0 5px; color: #666; &:hover { color: #000; } } } nav { background: #ccc; width: 500px; margin: 10px auto; } nav a { float: left; padding: 0 5px; color: #666; } nav a:hover { color: #000; } -
CSS SCSS the parent selector nesting nav { background: #ccc;
width: 500px; margin: 10px auto; a { float: left; padding: 0 5px; color: #666; &:hover { color: #000; } } } nav { background: #ccc; width: 500px; margin: 10px auto; } nav a { float: left; padding: 0 5px; color: #666; } nav a:hover { color: #000; } -
CSS SCSS the parent selector nesting nav { background: #ccc;
width: 500px; margin: 10px auto; a { float: left; padding: 0 5px; color: #666; &:hover { color: #000; } } } nav { background: #ccc; width: 500px; margin: 10px auto; } nav a { float: left; padding: 0 5px; color: #666; } nav a:hover { color: #000; } -
CSS SCSS nav { background: #ccc; width: 500px; margin: 10px
auto; a { float: left; padding: 0 5px; color: #666; &:hover { color: #000; } } } nav { background: #ccc; width: 500px; margin: 10px auto; } nav a { float: left; padding: 0 5px; color: #666; } nav a:hover { color: #000; } -
CSS nav { width: 500px; margin: 10px auto; background: #ccc;
a { float: left; display: block; padding: 0 5px; color: #666; &:hover { color: #000; }}} SCSS SCSS doesn’t care about whitespace nav { background: #ccc; width: 500px; margin: 10px auto; a { float: left; padding: 0 5px; color: #666; &:hover { color: #000; } } } nav { background: #ccc; width: 500px; margin: 10px auto; } nav a { float: left; padding: 0 5px; color: #666; } nav a:hover { color: #000; } -
CSS SCSS nav { background: #ccc; width: 500px; margin: 10px
auto; a { float: left; padding: 0 5px; color: #666; &:hover { color: #000; } } } nav { background: #ccc; width: 500px; margin: 10px auto; } nav a { float: left; padding: 0 5px; color: #666; } nav a:hover { color: #000; } -
CSS SCSS Sass nav background: #ccc width: 500px margin: 10px
auto a float: left padding: 0 5px color: #666 &:hover color: #000 nav { background: #ccc; width: 500px; margin: 10px auto; a { float: left; padding: 0 5px; color: #666; &:hover { color: #000; } } } nav { background: #ccc; width: 500px; margin: 10px auto; } nav a { float: left; padding: 0 5px; color: #666; } nav a:hover { color: #000; } -
CSS SCSS Sass nav background: #ccc width: 500px margin: 10px
auto a float: left padding: 0 5px color: #666 &:hover color: #000 nav { background: #ccc; width: 500px; margin: 10px auto; a { float: left; padding: 0 5px; color: #666; &:hover { color: #000; } } } nav { background: #ccc; width: 500px; margin: 10px auto; } nav a { float: left; padding: 0 5px; color: #666; } nav a:hover { color: #000; } whitespace is important -
CSS SCSS Sass nav background: #ccc width: 500px margin: 10px
auto a float: left padding: 0 5px color: #666 &:hover color: #000 nav { background: #ccc; width: 500px; margin: 10px auto; a { float: left; padding: 0 5px; color: #666; &:hover { color: #000; } } } nav { background: #ccc; width: 500px; margin: 10px auto; } nav a { float: left; padding: 0 5px; color: #666; } nav a:hover { color: #000; } -
CSS SCSS Sass nav background: #ccc width: 500px margin: 10px
auto a float: left padding: 0 5px color: #666 &:hover color: #000 nav { background: #ccc; width: 500px; margin: 10px auto; a { float: left; padding: 0 5px; color: #666; &:hover { color: #000; } } } nav { background: #ccc; width: 500px; margin: 10px auto; } nav a { float: left; padding: 0 5px; color: #666; } nav a:hover { color: #000; } -
CSS SCSS Sass nav background: #ccc width: 500px margin: 10px
auto a float: left padding: 0 5px color: #666 &:hover color: #000 nav { background: #ccc; width: 500px; margin: 10px auto; a { float: left; padding: 0 5px; color: #666; &:hover { color: #000; } } } nav { background: #ccc; width: 500px; margin: 10px auto; } nav a { float: left; padding: 0 5px; color: #666; } nav a:hover { color: #000; } -
• the “newer” syntax • a super set of CSS
SCSS Sass Advantages of each… -
• the “newer” syntax • a super set of CSS
• very similar to CSS SCSS Sass Advantages of each… -
• the “newer” syntax • a super set of CSS
• very similar to CSS • low barrier to entry SCSS Sass Advantages of each… -
• the “newer” syntax • a super set of CSS
• very similar to CSS • low barrier to entry • allows for single-line rules SCSS Sass Advantages of each… -
• the “newer” syntax • a super set of CSS
• very similar to CSS • low barrier to entry • allows for single-line rules • more flexible for expression SCSS Sass Advantages of each… -
• the “newer” syntax • a super set of CSS
• very similar to CSS • low barrier to entry • allows for single-line rules • more flexible for expression • compatible with many CSS parsers SCSS Sass Advantages of each… -
• the “newer” syntax • a super set of CSS
• very similar to CSS • low barrier to entry • allows for single-line rules • more flexible for expression • compatible with many CSS parsers • easy to integrate with existing CSS SCSS Sass Advantages of each… -
• the “newer” syntax • a super set of CSS
• very similar to CSS • low barrier to entry • allows for single-line rules • more flexible for expression • compatible with many CSS parsers • easy to integrate with existing CSS • DRY SCSS Sass Advantages of each… -
• the “newer” syntax • a super set of CSS
• very similar to CSS • low barrier to entry • allows for single-line rules • more flexible for expression • compatible with many CSS parsers • easy to integrate with existing CSS • DRY • the “original” syntax SCSS Sass Advantages of each… -
• the “newer” syntax • a super set of CSS
• very similar to CSS • low barrier to entry • allows for single-line rules • more flexible for expression • compatible with many CSS parsers • easy to integrate with existing CSS • DRY • the “original” syntax • no curly braces or semicolons SCSS Sass Advantages of each… -
• the “newer” syntax • a super set of CSS
• very similar to CSS • low barrier to entry • allows for single-line rules • more flexible for expression • compatible with many CSS parsers • easy to integrate with existing CSS • DRY • the “original” syntax • no curly braces or semicolons • white-space aware SCSS Sass Advantages of each… -
• the “newer” syntax • a super set of CSS
• very similar to CSS • low barrier to entry • allows for single-line rules • more flexible for expression • compatible with many CSS parsers • easy to integrate with existing CSS • DRY • the “original” syntax • no curly braces or semicolons • white-space aware • shortcuts for @mixin and @include SCSS Sass Advantages of each… -
• the “newer” syntax • a super set of CSS
• very similar to CSS • low barrier to entry • allows for single-line rules • more flexible for expression • compatible with many CSS parsers • easy to integrate with existing CSS • DRY • the “original” syntax • no curly braces or semicolons • white-space aware • shortcuts for @mixin and @include • more scannable SCSS Sass Advantages of each… -
• the “newer” syntax • a super set of CSS
• very similar to CSS • low barrier to entry • allows for single-line rules • more flexible for expression • compatible with many CSS parsers • easy to integrate with existing CSS • DRY • the “original” syntax • no curly braces or semicolons • white-space aware • shortcuts for @mixin and @include • more scannable • more concise, better for teams SCSS Sass Advantages of each… -
• the “newer” syntax • a super set of CSS
• very similar to CSS • low barrier to entry • allows for single-line rules • more flexible for expression • compatible with many CSS parsers • easy to integrate with existing CSS • DRY • the “original” syntax • no curly braces or semicolons • white-space aware • shortcuts for @mixin and @include • more scannable • more concise, better for teams • enforces one declaration per line SCSS Sass Advantages of each… -
• the “newer” syntax • a super set of CSS
• very similar to CSS • low barrier to entry • allows for single-line rules • more flexible for expression • compatible with many CSS parsers • easy to integrate with existing CSS • DRY • the “original” syntax • no curly braces or semicolons • white-space aware • shortcuts for @mixin and @include • more scannable • more concise, better for teams • enforces one declaration per line • cleaner merges SCSS Sass Advantages of each… -
• the “newer” syntax • a super set of CSS
• very similar to CSS • low barrier to entry • allows for single-line rules • more flexible for expression • compatible with many CSS parsers • easy to integrate with existing CSS • DRY • the “original” syntax • no curly braces or semicolons • white-space aware • shortcuts for @mixin and @include • more scannable • more concise, better for teams • enforces one declaration per line • cleaner merges • DRY, arguably more so SCSS Sass Advantages of each… -
• the “newer” syntax • a super set of CSS
• very similar to CSS • low barrier to entry • allows for single-line rules • more flexible for expression • compatible with many CSS parsers • easy to integrate with existing CSS • DRY • the “original” syntax • no curly braces or semicolons • white-space aware • shortcuts for @mixin and @include • more scannable • more concise, better for teams • enforces one declaration per line • cleaner merges • DRY, arguably more so SCSS Sass Try both …you may want to use both. Advantages of each… -
• Add Compass to a project • @import & partials
• @extend • nesting • $variables • @mixin • sprites • inline images • CSS3 Today’s Roadmap -
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Sass Why</title> <link href="reset.css"
rel="stylesheet" /> <link href="messaging.css" rel="stylesheet" /> </head> <body> <!-- content here --> </body> </html> messaging.html -
<div class="flash-info"> <img src="images/icon-info.png" alt="info icon" class="flash-icon"> <p>You have mail.</p>
</div> <div class="flash-success"> <img src="images/icon-success.png" alt="success icon" class="flash-icon"> <p>Settings updated!</p> </div> <div class="flash-error"> <img src="images/icon-error.png" alt="error icon" class="flash-icon"> <p>Please fix the following errors:</p> <ul> <li>Username requires more pazazz.</li> <li>Password is too easy to hack.</li> <li>You must be at least this tall to ride this ride.</li> </ul> </div> Our content… -
<div class="flash-info"> <img src="images/icon-info.png" alt="info icon" class="flash-icon"> <p>You have mail.</p>
</div> <div class="flash-success"> <img src="images/icon-success.png" alt="success icon" class="flash-icon"> <p>Settings updated!</p> </div> <div class="flash-error"> <img src="images/icon-error.png" alt="error icon" class="flash-icon"> <p>Please fix the following errors:</p> <ul> <li>Username requires more pazazz.</li> <li>Password is too easy to hack.</li> <li>You must be at least this tall to ride this ride.</li> </ul> </div> Our content… info -
<div class="flash-info"> <img src="images/icon-info.png" alt="info icon" class="flash-icon"> <p>You have mail.</p>
</div> <div class="flash-success"> <img src="images/icon-success.png" alt="success icon" class="flash-icon"> <p>Settings updated!</p> </div> <div class="flash-error"> <img src="images/icon-error.png" alt="error icon" class="flash-icon"> <p>Please fix the following errors:</p> <ul> <li>Username requires more pazazz.</li> <li>Password is too easy to hack.</li> <li>You must be at least this tall to ride this ride.</li> </ul> </div> Our content… success -
<div class="flash-info"> <img src="images/icon-info.png" alt="info icon" class="flash-icon"> <p>You have mail.</p>
</div> <div class="flash-success"> <img src="images/icon-success.png" alt="success icon" class="flash-icon"> <p>Settings updated!</p> </div> <div class="flash-error"> <img src="images/icon-error.png" alt="error icon" class="flash-icon"> <p>Please fix the following errors:</p> <ul> <li>Username requires more pazazz.</li> <li>Password is too easy to hack.</li> <li>You must be at least this tall to ride this ride.</li> </ul> </div> Our content… error -
body { background: #e3e3e3; margin: 20px; font: 16px/24px sans-serif; }
ul { list-style: disc; margin-left: 20px; } messaging.css -
body { background: #e3e3e3; margin: 20px; font: 16px/24px sans-serif; }
ul { list-style: disc; margin-left: 20px; } messaging.css layout -
body { background: #e3e3e3; margin: 20px; font: 16px/24px sans-serif; }
ul { list-style: disc; margin-left: 20px; } messaging.css prose -
.flash-info { position: relative; margin: 0 auto 15px; width: 435px;
background: #a4a4a4; border-radius: 5px; padding: 10px 50px 10px 15px; color: white; font-weight: bold; text-shadow: 0 -1px #838484; } .flash-success { position: relative; margin: 0 auto 15px; width: 435px; background: #1b942a; border-radius: 5px; padding: 10px 50px 10px 15px; color: white; font-weight: bold; text-shadow: 0 -1px #1a7e1c; } .flash-error { position: relative; margin: 0 auto 15px; width: 435px; background: #ef9000; border-radius: 5px; padding: 10px 50px 10px 15px; color: white; font-weight: bold; text-shadow: 0 -1px #e8541c; } .flash-error li { font-weight: normal; } .flash-icon { display: block; position: absolute; top: 11px; right: 12px; } messaging.css -
.flash-info { position: relative; margin: 0 auto 15px; width: 435px;
background: #a4a4a4; border-radius: 5px; padding: 10px 50px 10px 15px; color: white; font-weight: bold; text-shadow: 0 -1px #838484; } .flash-success { position: relative; margin: 0 auto 15px; width: 435px; background: #1b942a; border-radius: 5px; padding: 10px 50px 10px 15px; color: white; font-weight: bold; text-shadow: 0 -1px #1a7e1c; } .flash-error { position: relative; margin: 0 auto 15px; width: 435px; background: #ef9000; border-radius: 5px; padding: 10px 50px 10px 15px; color: white; font-weight: bold; text-shadow: 0 -1px #e8541c; } .flash-error li { font-weight: normal; } .flash-icon { display: block; position: absolute; top: 11px; right: 12px; } messaging.css info -
.flash-info { position: relative; margin: 0 auto 15px; width: 435px;
background: #a4a4a4; border-radius: 5px; padding: 10px 50px 10px 15px; color: white; font-weight: bold; text-shadow: 0 -1px #838484; } .flash-success { position: relative; margin: 0 auto 15px; width: 435px; background: #1b942a; border-radius: 5px; padding: 10px 50px 10px 15px; color: white; font-weight: bold; text-shadow: 0 -1px #1a7e1c; } .flash-error { position: relative; margin: 0 auto 15px; width: 435px; background: #ef9000; border-radius: 5px; padding: 10px 50px 10px 15px; color: white; font-weight: bold; text-shadow: 0 -1px #e8541c; } .flash-error li { font-weight: normal; } .flash-icon { display: block; position: absolute; top: 11px; right: 12px; } messaging.css success -
.flash-info { position: relative; margin: 0 auto 15px; width: 435px;
background: #a4a4a4; border-radius: 5px; padding: 10px 50px 10px 15px; color: white; font-weight: bold; text-shadow: 0 -1px #838484; } .flash-success { position: relative; margin: 0 auto 15px; width: 435px; background: #1b942a; border-radius: 5px; padding: 10px 50px 10px 15px; color: white; font-weight: bold; text-shadow: 0 -1px #1a7e1c; } .flash-error { position: relative; margin: 0 auto 15px; width: 435px; background: #ef9000; border-radius: 5px; padding: 10px 50px 10px 15px; color: white; font-weight: bold; text-shadow: 0 -1px #e8541c; } .flash-error li { font-weight: normal; } .flash-icon { display: block; position: absolute; top: 11px; right: 12px; } messaging.css error -
.flash-info { position: relative; margin: 0 auto 15px; width: 435px;
background: #a4a4a4; border-radius: 5px; padding: 10px 50px 10px 15px; color: white; font-weight: bold; text-shadow: 0 -1px #838484; } .flash-success { position: relative; margin: 0 auto 15px; width: 435px; background: #1b942a; border-radius: 5px; padding: 10px 50px 10px 15px; color: white; font-weight: bold; text-shadow: 0 -1px #1a7e1c; } .flash-error { position: relative; margin: 0 auto 15px; width: 435px; background: #ef9000; border-radius: 5px; padding: 10px 50px 10px 15px; color: white; font-weight: bold; text-shadow: 0 -1px #e8541c; } .flash-error li { font-weight: normal; } .flash-icon { display: block; position: absolute; top: 11px; right: 12px; } messaging.css error items -
.flash-info { position: relative; margin: 0 auto 15px; width: 435px;
background: #a4a4a4; border-radius: 5px; padding: 10px 50px 10px 15px; color: white; font-weight: bold; text-shadow: 0 -1px #838484; } .flash-success { position: relative; margin: 0 auto 15px; width: 435px; background: #1b942a; border-radius: 5px; padding: 10px 50px 10px 15px; color: white; font-weight: bold; text-shadow: 0 -1px #1a7e1c; } .flash-error { position: relative; margin: 0 auto 15px; width: 435px; background: #ef9000; border-radius: 5px; padding: 10px 50px 10px 15px; color: white; font-weight: bold; text-shadow: 0 -1px #e8541c; } .flash-error li { font-weight: normal; } .flash-icon { display: block; position: absolute; top: 11px; right: 12px; } messaging.css icon -
html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acron ym,address,big,cite,code,del,dfn,em,img,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt ,var,b,u,i,center,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoo t,thead,tr,th,td,article,aside,canvas,details,embed,figure,figcaption,footer,header,hgr oup,menu,nav,output,ruby,section,summary,time,mark,audio,video{border:0;font-size: 100%;font:inherit;vertical-align:baseline;margin:0;padding:0}body{line-height:1} ol,ul{list-style:none}table{border-collapse:collapse;border-spacing:0} caption,th,td{text-align:left;font-weight:normal;vertical-align:middle} q,blockquote{quotes:none} q:before,q:after,blockquote:before,blockquote:after{content:none}a
img{border:none} article,aside,details,figcaption,figure,footer,header,hgroup,menu,nav,section,summary{d isplay:block} reset.css -
html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acron ym,address,big,cite,code,del,dfn,em,img,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt ,var,b,u,i,center,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoo t,thead,tr,th,td,article,aside,canvas,details,embed,figure,figcaption,footer,header,hgr oup,menu,nav,output,ruby,section,summary,time,mark,audio,video{border:0;font-size: 100%;font:inherit;vertical-align:baseline;margin:0;padding:0}body{line-height:1} ol,ul{list-style:none}table{border-collapse:collapse;border-spacing:0} caption,th,td{text-align:left;font-weight:normal;vertical-align:middle} q,blockquote{quotes:none} q:before,q:after,blockquote:before,blockquote:after{content:none}a
img{border:none} article,aside,details,figcaption,figure,footer,header,hgroup,menu,nav,section,summary{d isplay:block} reset.css Eric Meyer’s Reset -
html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acron ym,address,big,cite,code,del,dfn,em,img,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt ,var,b,u,i,center,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoo t,thead,tr,th,td,article,aside,canvas,details,embed,figure,figcaption,footer,header,hgr oup,menu,nav,output,ruby,section,summary,time,mark,audio,video{border:0;font-size: 100%;font:inherit;vertical-align:baseline;margin:0;padding:0}body{line-height:1} ol,ul{list-style:none}table{border-collapse:collapse;border-spacing:0} caption,th,td{text-align:left;font-weight:normal;vertical-align:middle} q,blockquote{quotes:none} q:before,q:after,blockquote:before,blockquote:after{content:none}a
img{border:none} article,aside,details,figcaption,figure,footer,header,hgroup,menu,nav,section,summary{d isplay:block} reset.css Eric Meyer’s Reset • Browsers have a default style sheet -
html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acron ym,address,big,cite,code,del,dfn,em,img,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt ,var,b,u,i,center,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoo t,thead,tr,th,td,article,aside,canvas,details,embed,figure,figcaption,footer,header,hgr oup,menu,nav,output,ruby,section,summary,time,mark,audio,video{border:0;font-size: 100%;font:inherit;vertical-align:baseline;margin:0;padding:0}body{line-height:1} ol,ul{list-style:none}table{border-collapse:collapse;border-spacing:0} caption,th,td{text-align:left;font-weight:normal;vertical-align:middle} q,blockquote{quotes:none} q:before,q:after,blockquote:before,blockquote:after{content:none}a
img{border:none} article,aside,details,figcaption,figure,footer,header,hgroup,menu,nav,section,summary{d isplay:block} reset.css Eric Meyer’s Reset • Browsers have a default style sheet • Browser style sheets are different -
html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acron ym,address,big,cite,code,del,dfn,em,img,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt ,var,b,u,i,center,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoo t,thead,tr,th,td,article,aside,canvas,details,embed,figure,figcaption,footer,header,hgr oup,menu,nav,output,ruby,section,summary,time,mark,audio,video{border:0;font-size: 100%;font:inherit;vertical-align:baseline;margin:0;padding:0}body{line-height:1} ol,ul{list-style:none}table{border-collapse:collapse;border-spacing:0} caption,th,td{text-align:left;font-weight:normal;vertical-align:middle} q,blockquote{quotes:none} q:before,q:after,blockquote:before,blockquote:after{content:none}a
img{border:none} article,aside,details,figcaption,figure,footer,header,hgroup,menu,nav,section,summary{d isplay:block} reset.css Eric Meyer’s Reset • Browsers have a default style sheet • Browser style sheets are different • A reset style sheet overrides default browser styles -
Add Compass to project ~ ~/sass-why ~/sass-why cd sass-why compass
create compass compile create stylesheets/messaging.css create stylesheets/reset.css ~/sass-why -
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Sass Why</title> <link href="reset.css"
rel="stylesheet" /> <link href="messaging.css" rel="stylesheet" /> </head> <body> <div class="flash-info"> ••• <div class="flash-success"> ••• <div class="flash-error"> ••• </body> </html> messaging.html -
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Sass Why</title> <link href="reset.css"
rel="stylesheet" /> <link href="messaging.css" rel="stylesheet" /> </head> <body> <div class="flash-info"> ••• <div class="flash-success"> ••• <div class="flash-error"> ••• </body> </html> messaging.html update links -
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Sass Why</title> <link href="stylesheets/reset.css"
rel="stylesheet" /> <link href="stylesheets/messaging.css" rel="stylesheet" /> </head> <body> <div class="flash-info"> ••• <div class="flash-success"> ••• <div class="flash-error"> ••• </body> </html> messaging.html update links -
• not during page render in browser like in CSS
@import (in Sass) -
• not during page render in browser like in CSS
• when compiling Sass to CSS @import (in Sass) -
• not during page render in browser like in CSS
• when compiling Sass to CSS • organize your styles into logical partials @import (in Sass) -
• not during page render in browser like in CSS
• when compiling Sass to CSS • organize your styles into logical partials • combine many files into one @import (in Sass) -
• not during page render in browser like in CSS
• when compiling Sass to CSS • organize your styles into logical partials • combine many files into one • serve fewer css files per request @import (in Sass) -
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Sass Why</title> <link href="stylesheets/reset.css"
rel="stylesheet" /> <link href="stylesheets/messaging.css" rel="stylesheet" /> </head> <body> <div class="flash-info"> ••• <div class="flash-success"> ••• <div class="flash-error"> ••• </body> </html> messaging.html -
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Sass Why</title> <link href="stylesheets/reset.css"
rel="stylesheet" /> <link href="stylesheets/messaging.css" rel="stylesheet" /> </head> <body> <div class="flash-info"> ••• <div class="flash-success"> ••• <div class="flash-error"> ••• </body> </html> messaging.html remove these -
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Sass Why</title> <link href="stylesheets/screen.css"
rel="stylesheet" /> </head> <body> <div class="flash-info"> ••• <div class="flash-success"> ••• <div class="flash-error"> ••• </body> </html> messaging.html add screen.css -
body { background: #e3e3e3; margin: 20px; font: 16px/24px sans-serif; }
ul { list-style: disc; margin-left: 20px; } _layout.scss layout prose -
_messaging.scss .flash-info { position: relative; margin: 0 auto 15px; width:
435px; background: #a4a4a4; border-radius: 5px; padding: 10px 50px 10px 15px; color: white; font-weight: bold; text-shadow: 0 -1px #838484; } .flash-success { position: relative; margin: 0 auto 15px; width: 435px; background: #1b942a; border-radius: 5px; padding: 10px 50px 10px 15px; color: white; font-weight: bold; text-shadow: 0 -1px #1a7e1c; } .flash-error { position: relative; margin: 0 auto 15px; width: 435px; background: #ef9000; border-radius: 5px; padding: 10px 50px 10px 15px; color: white; font-weight: bold; text-shadow: 0 -1px #e8541c; } .flash-error li { font-weight: normal; } .flash-icon { display: block; position: absolute; top: 11px; right: 12px; } -
When one element should have all the styles of another,
plus its own styles. @extend -
_messaging.scss .flash-info { position: relative; margin: 0 auto 15px; width:
435px; background: #a4a4a4; border-radius: 5px; padding: 10px 50px 10px 15px; color: white; font-weight: bold; text-shadow: 0 -1px #838484; } .flash-success { position: relative; margin: 0 auto 15px; width: 435px; background: #1b942a; border-radius: 5px; padding: 10px 50px 10px 15px; color: white; font-weight: bold; text-shadow: 0 -1px #1a7e1c; } .flash-error { position: relative; margin: 0 auto 15px; width: 435px; background: #ef9000; border-radius: 5px; padding: 10px 50px 10px 15px; color: white; font-weight: bold; text-shadow: 0 -1px #e8541c; } .flash-error li { font-weight: normal; } .flash-icon { display: block; position: absolute; top: 11px; right: 12px; } -
_messaging.scss .flash-info { position: relative; margin: 0 auto 15px; width:
435px; background: #a4a4a4; border-radius: 5px; padding: 10px 50px 10px 15px; color: white; font-weight: bold; text-shadow: 0 -1px #838484; } .flash-success { position: relative; margin: 0 auto 15px; width: 435px; background: #1b942a; border-radius: 5px; padding: 10px 50px 10px 15px; color: white; font-weight: bold; text-shadow: 0 -1px #1a7e1c; } .flash-error { position: relative; margin: 0 auto 15px; width: 435px; background: #ef9000; border-radius: 5px; padding: 10px 50px 10px 15px; color: white; font-weight: bold; text-shadow: 0 -1px #e8541c; } .flash-error li { font-weight: normal; } .flash-icon { display: block; position: absolute; top: 11px; right: 12px; } unique style declarations -
_messaging.scss .flash-info, .flash-success, .flash-error { position: relative; margin: 0 auto
15px; width: 435px; border-radius: 5px; padding: 10px 50px 10px 15px; color: white; font-weight: bold; } .flash-info { background: #a4a4a4; text-shadow: 0 -1px #838484; } .flash-success { background: #1b942a; text-shadow: 0 -1px #1a7e1c; } .flash-error { background: #ef9000; text-shadow: 0 -1px #e8541c; } .flash-error li { font-weight: normal; } .flash-icon { display: block; position: absolute; top: 11px; right: 12px; } -
_messaging.scss .flash-info, .flash-success, .flash-error { position: relative; margin: 0 auto
15px; width: 435px; border-radius: 5px; padding: 10px 50px 10px 15px; color: white; font-weight: bold; } .flash-info { background: #a4a4a4; text-shadow: 0 -1px #838484; } .flash-success { background: #1b942a; text-shadow: 0 -1px #1a7e1c; } .flash-error { background: #ef9000; text-shadow: 0 -1px #e8541c; } .flash-error li { font-weight: normal; } .flash-icon { display: block; position: absolute; top: 11px; right: 12px; } -
_messaging.scss .flash-message { position: relative; margin: 0 auto 15px; width:
435px; border-radius: 5px; padding: 10px 50px 10px 15px; color: white; font-weight: bold; } .flash-info { background: #a4a4a4; text-shadow: 0 -1px #838484; } .flash-success { background: #1b942a; text-shadow: 0 -1px #1a7e1c; } .flash-error { background: #ef9000; text-shadow: 0 -1px #e8541c; } .flash-error li { font-weight: normal; } .flash-icon { display: block; position: absolute; top: 11px; right: 12px; } -
_messaging.scss .flash-message { position: relative; margin: 0 auto 15px; width:
435px; border-radius: 5px; padding: 10px 50px 10px 15px; color: white; font-weight: bold; } .flash-info { background: #a4a4a4; text-shadow: 0 -1px #838484; } .flash-success { background: #1b942a; text-shadow: 0 -1px #1a7e1c; } .flash-error { background: #ef9000; text-shadow: 0 -1px #e8541c; } .flash-error li { font-weight: normal; } .flash-icon { display: block; position: absolute; top: 11px; right: 12px; } -
_messaging.scss .flash-message { position: relative; margin: 0 auto 15px; width:
435px; border-radius: 5px; padding: 10px 50px 10px 15px; color: white; font-weight: bold; } .flash-info { @extend .flash-message; background: #a4a4a4; text-shadow: 0 -1px #838484; } .flash-success { @extend .flash-message; background: #1b942a; text-shadow: 0 -1px #1a7e1c; } .flash-error { @extend .flash-message; background: #ef9000; text-shadow: 0 -1px #e8541c; } .flash-error li { font-weight: normal; } .flash-icon { display: block; position: absolute; top: 11px; right: 12px; } -
_messaging.scss .flash-message { position: relative; margin: 0 auto 15px; width:
435px; border-radius: 5px; padding: 10px 50px 10px 15px; color: white; font-weight: bold; } .flash-info { @extend .flash-message; background: #a4a4a4; text-shadow: 0 -1px #838484; } .flash-success { @extend .flash-message; background: #1b942a; text-shadow: 0 -1px #1a7e1c; } .flash-error { @extend .flash-message; background: #ef9000; text-shadow: 0 -1px #e8541c; } .flash-error li { font-weight: normal; } .flash-icon { display: block; position: absolute; top: 11px; right: 12px; } -
.flash-message, .flash-info, .flash-success, .flash-error { position: relative; margin: 0 auto
15px; width: 435px; border-radius: 5px; padding: 10px 50px 10px 15px; color: white; font-weight: bold; } .flash-info { background: #a4a4a4; text-shadow: 0 -1px #838484; } .flash-success { background: #1b942a; text-shadow: 0 -1px #1a7e1c; } .flash-error { background: #ef9000; text-shadow: 0 -1px #e8541c; } .flash-error li { font-weight: normal; } .flash-icon { display: block; position: absolute; top: 11px; right: 12px; } Compiled CSS -
_messaging.scss .flash-info { position: relative; margin: 0 auto 15px; width:
435px; border-radius: 5px; padding: 10px 50px 10px 15px; color: white; font-weight: bold; background: #a4a4a4; text-shadow: 0 -1px #838484; } .flash-success { @extend .flash-info; background: #1b942a; text-shadow: 0 -1px #1a7e1c; } .flash-error { @extend .flash-info; background: #ef9000; text-shadow: 0 -1px #e8541c; } .flash-error li { font-weight: normal; } .flash-icon { display: block; position: absolute; top: 11px; right: 12px; } -
_messaging.scss .flash-info { position: relative; margin: 0 auto 15px; width:
435px; border-radius: 5px; padding: 10px 50px 10px 15px; color: white; font-weight: bold; background: #a4a4a4; text-shadow: 0 -1px #838484; } .flash-success { @extend .flash-info; background: #1b942a; text-shadow: 0 -1px #1a7e1c; } .flash-error { @extend .flash-info; background: #ef9000; text-shadow: 0 -1px #e8541c; } .flash-error li { font-weight: normal; } .flash-icon { display: block; position: absolute; top: 11px; right: 12px; } -
_messaging.scss .flash-info { position: relative; margin: 0 auto 15px; width:
435px; border-radius: 5px; padding: 10px 50px 10px 15px; color: white; font-weight: bold; background: #a4a4a4; text-shadow: 0 -1px #838484; } .flash-success { @extend .flash-info; background: #1b942a; text-shadow: 0 -1px #1a7e1c; } .flash-error { @extend .flash-info; background: #ef9000; text-shadow: 0 -1px #e8541c; } .flash-error li { font-weight: normal; } .flash-icon { display: block; position: absolute; top: 11px; right: 12px; } -
_messaging.scss .flash-info { position: relative; margin: 0 auto 15px; width:
435px; border-radius: 5px; padding: 10px 50px 10px 15px; color: white; font-weight: bold; background: #a4a4a4; text-shadow: 0 -1px #838484; } .flash-success { @extend .flash-info; background: #1b942a; text-shadow: 0 -1px #1a7e1c; } .flash-error { @extend .flash-info; background: #ef9000; text-shadow: 0 -1px #e8541c; } .flash-error li { font-weight: normal; } .flash-icon { display: block; position: absolute; top: 11px; right: 12px; } -
_messaging.scss .flash-info { position: relative; margin: 0 auto 15px; width:
435px; border-radius: 5px; padding: 10px 50px 10px 15px; color: white; font-weight: bold; background: #a4a4a4; text-shadow: 0 -1px #838484; } .flash-success { @extend .flash-info; background: #1b942a; text-shadow: 0 -1px #1a7e1c; } .flash-error { @extend .flash-info; background: #ef9000; text-shadow: 0 -1px #e8541c; } .flash-error li { font-weight: normal; } .flash-icon { display: block; position: absolute; top: 11px; right: 12px; } -
.flash-info, .flash-success, .flash-error { position: relative; margin: 0 auto 15px;
width: 435px; border-radius: 5px; padding: 10px 50px 10px 15px; color: white; font-weight: bold; background: #a4a4a4; text-shadow: 0 -1px #838484; } .flash-success { background: #1b942a; text-shadow: 0 -1px #1a7e1c; } .flash-error { background: #ef9000; text-shadow: 0 -1px #e8541c; } .flash-error li { font-weight: normal; } .flash-icon { display: block; position: absolute; top: 11px; right: 12px; } Compiled CSS -
• group styles together • avoid duplication of selectors •
keep your code DRY Nesting -
• group styles together • avoid duplication of selectors •
keep your code DRY Sass nesting ≠ html structure Nesting -
• group styles together • avoid duplication of selectors •
keep your code DRY Sass nesting ≠ html structure Nesting FASTER TRAFFIC KEEP LEFT -
Warning about Nesting .subset-section background-color: #FFF width: 960px .subset-skus width:
790px .subset-selection float: left width: 790px .registrant-needs margin-bottom: 10px text-align: right .subset-attributes width: 430px float: left .subset-pricing display: block text-align: right .price-special font-size: 11px .currency font-size: 16px -
Warning about Nesting .subset-section { background-color: white; width: 960px; }
.subset-section .subset-skus { width: 790px; } .subset-section .subset-skus .subset-selection { float: left; width: 790px; } .subset-section .subset-skus .subset-selection .registrant-needs { margin-bottom: 10px; text-align: right; } .subset-section .subset-skus .subset-selection .registrant-needs .subset-attributes { width: 430px; float: left; } .subset-section .subset-skus .subset-selection .registrant-needs .subset-attributes .subset-pricing display: block; text-align: right; } .subset-section .subset-skus .subset-selection .registrant-needs .subset-attributes .subset-prici font-size: 11px; } .subset-section .subset-skus .subset-selection .registrant-needs .subset-attributes .subset-prici font-size: 16px; } -
_messaging.scss .flash-message { position: relative; margin: 0 auto 15px; width:
435px; border-radius: 5px; padding: 10px 50px 10px 15px; color: white; font-weight: bold; } .flash-info { @extend .flash-message; background: #a4a4a4; text-shadow: 0 -1px #838484; } .flash-success { @extend .flash-message; background: #1b942a; text-shadow: 0 -1px #1a7e1c; } .flash-error { @extend .flash-message; background: #ef9000; text-shadow: 0 -1px #e8541c; } .flash-error li { font-weight: normal; } .flash-icon { display: block; position: absolute; top: 11px; right: 12px; } -
_messaging.scss .flash-message { position: relative; margin: 0 auto 15px; width:
435px; border-radius: 5px; padding: 10px 50px 10px 15px; color: white; font-weight: bold; } .flash-info { @extend .flash-message; background: #a4a4a4; text-shadow: 0 -1px #838484; } .flash-success { @extend .flash-message; background: #1b942a; text-shadow: 0 -1px #1a7e1c; } .flash-error { @extend .flash-message; background: #ef9000; text-shadow: 0 -1px #e8541c; } .flash-error li { font-weight: normal; } .flash-icon { display: block; position: absolute; top: 11px; right: 12px; } -
_messaging.scss .flash-message { position: relative; margin: 0 auto 15px; width:
435px; border-radius: 5px; padding: 10px 50px 10px 15px; color: white; font-weight: bold; } .flash-info { @extend .flash-message; background: #a4a4a4; text-shadow: 0 -1px #838484; } .flash-success { @extend .flash-message; background: #1b942a; text-shadow: 0 -1px #1a7e1c; } .flash-error { @extend .flash-message; background: #ef9000; text-shadow: 0 -1px #e8541c; .flash-error li { font-weight: normal; } } .flash-icon { display: block; position: absolute; top: 11px; right: 12px; } -
_messaging.scss .flash-message { position: relative; margin: 0 auto 15px; width:
435px; border-radius: 5px; padding: 10px 50px 10px 15px; color: white; font-weight: bold; } .flash-info { @extend .flash-message; background: #a4a4a4; text-shadow: 0 -1px #838484; } .flash-success { @extend .flash-message; background: #1b942a; text-shadow: 0 -1px #1a7e1c; } .flash-error { @extend .flash-message; background: #ef9000; text-shadow: 0 -1px #e8541c; .flash-error li { font-weight: normal; } } .flash-icon { display: block; position: absolute; top: 11px; right: 12px; } -
_messaging.scss .flash-message { position: relative; margin: 0 auto 15px; width:
435px; border-radius: 5px; padding: 10px 50px 10px 15px; color: white; font-weight: bold; } .flash-info { @extend .flash-message; background: #a4a4a4; text-shadow: 0 -1px #838484; } .flash-success { @extend .flash-message; background: #1b942a; text-shadow: 0 -1px #1a7e1c; } .flash-error { @extend .flash-message; background: #ef9000; text-shadow: 0 -1px #e8541c; li { font-weight: normal; } } .flash-icon { display: block; position: absolute; top: 11px; right: 12px; } -
screen.css .flash-message, .flash-info, .flash-success, .flash-error { position: relative; margin: 0
auto 15px; width: 435px; border-radius: 5px; padding: 10px 50px 10px 15px; color: white; font-weight: bold; } .flash-info { background: #a4a4a4; text-shadow: 0 -1px #838484; } .flash-success { background: #1b942a; text-shadow: 0 -1px #1a7e1c; } .flash-error { background: #ef9000; text-shadow: 0 -1px #e8541c; } .flash-error li { font-weight: normal; } .flash-icon { display: block; position: absolute; top: 11px; right: 12px; } -
screen.css .flash-message, .flash-info, .flash-success, .flash-error { position: relative; margin: 0
auto 15px; width: 435px; border-radius: 5px; padding: 10px 50px 10px 15px; color: white; font-weight: bold; } .flash-info { background: #a4a4a4; text-shadow: 0 -1px #838484; } .flash-success { background: #1b942a; text-shadow: 0 -1px #1a7e1c; } .flash-error { background: #ef9000; text-shadow: 0 -1px #e8541c; } .flash-error li { font-weight: normal; } output_style = :nested .flash-icon { display: block; position: absolute; top: 11px; right: 12px; } -
screen.css .flash-message, .flash-info, .flash-success, .flash-error { position: relative; margin: 0
auto 15px; width: 435px; border-radius: 5px; padding: 10px 50px 10px 15px; color: white; font-weight: bold; } .flash-info { background: #a4a4a4; text-shadow: 0 -1px #838484; } .flash-success { background: #1b942a; text-shadow: 0 -1px #1a7e1c; } .flash-error { background: #ef9000; text-shadow: 0 -1px #e8541c; } .flash-error li { font-weight: normal; } output_style = :nested .flash-icon { display: block; position: absolute; top: 11px; right: 12px; } -
screen.css .flash-message, .flash-info, .flash-success, .flash-error { position: relative; margin: 0
auto 15px; width: 435px; border-radius: 5px; padding: 10px 50px 10px 15px; color: white; font-weight: bold; } .flash-info { background: #a4a4a4; text-shadow: 0 -1px #838484; } .flash-success { background: #1b942a; text-shadow: 0 -1px #1a7e1c; } .flash-error { background: #ef9000; text-shadow: 0 -1px #e8541c; } .flash-error li { font-weight: normal; } output_style = :nested .flash-icon { display: block; position: absolute; top: 11px; right: 12px; } output_style -
screen.css .flash-message, .flash-info, .flash-success, .flash-error { position: relative; margin: 0
auto 15px; width: 435px; border-radius: 5px; padding: 10px 50px 10px 15px; color: white; font-weight: bold; } .flash-info { background: #a4a4a4; text-shadow: 0 -1px #838484; } .flash-success { background: #1b942a; text-shadow: 0 -1px #1a7e1c; } .flash-error { background: #ef9000; text-shadow: 0 -1px #e8541c; } .flash-error li { font-weight: normal; } output_style = :expanded .flash-icon { display: block; position: absolute; top: 11px; right: 12px; } -
screen.css .flash-message, .flash-info, .flash-success, .flash-error { position: relative; margin: 0
auto 15px; width: 435px; border-radius: 5px; padding: 10px 50px 10px 15px; color: white; font-weight: bold; } .flash-info { background: #a4a4a4; text-shadow: 0 -1px #838484; } .flash-success { background: #1b942a; text-shadow: 0 -1px #1a7e1c; } .flash-error { background: #ef9000; text-shadow: 0 -1px #e8541c; } .flash-error li { font-weight: normal; } .flash-icon { display: block; position: absolute; top: 11px; right: 12px; } output_style = :compact -
screen.css .flash-message,.flash-info,.flash-success,.flash-error{position:relative;margin:0 auto 15px;width: 435px;border-radius:5px;padding:10px 50px 10px 15px;color:white;font-weight:bold}.flash- info{background:#a4a4a4;text-shadow:0 -1px
#838484}.flash-success{background:#1b942a;text-shadow:0 -1px #1a7e1c}.flash-error{background:#ef9000;text-shadow:0 -1px #e8541c}.flash-error li{font- weight:normal}.flash-icon{display:block;position:absolute;top:11px;right:12px} output_style = :compressed -
_messaging.scss .flash-message { position: relative; margin: 0 auto 15px; width:
435px; border-radius: 5px; padding: 10px 50px 10px 15px; color: white; font-weight: bold; } .flash-info { @extend .flash-message; background: #a4a4a4; text-shadow: 0 -1px #838484; } .flash-success { @extend .flash-message; background: #1b942a; text-shadow: 0 -1px #1a7e1c; } .flash-error { @extend .flash-message; background: #ef9000; text-shadow: 0 -1px #e8541c; li { font-weight: normal; } } .flash-icon { display: block; position: absolute; top: 11px; right: 12px; } -
_messaging.sass .flash-message position: relative margin: 0 auto 15px; width: 435px;
border-radius: 5px padding: 10px 50px 10px 15px color: white font-weight: bold .flash-info @extend .flash-message background: #a4a4a4 text-shadow: 0 -1px #838484 .flash-success @extend .flash-message background: #1b942a text-shadow: 0 -1px #1a7e1c .flash-error @extend .flash-message background: #ef9000 text-shadow: 0 -1px #e8541c li font-weight: normal .flash-icon display: block position: absolute top: 11px right: 12px -
_messaging.sass .flash-message position: relative margin: 0 auto 15px; width: 435px;
border-radius: 5px padding: 10px 50px 10px 15px color: white font-weight: bold .flash-info @extend .flash-message background: #a4a4a4 text-shadow: 0 -1px #838484 .flash-success @extend .flash-message background: #1b942a text-shadow: 0 -1px #1a7e1c .flash-error @extend .flash-message background: #ef9000 text-shadow: 0 -1px #e8541c li font-weight: normal .flash-icon display: block position: absolute top: 11px right: 12px -
@import "compass/reset"; @import "layout"; @import "messaging"; screen.scss @import supports both
syntaxes, no changes here -
• containers for values • variable name define the purpose
of values $variables -
• containers for values • variable name define the purpose
of values • Five value types in Sass: $variables -
• containers for values • variable name define the purpose
of values • Five value types in Sass: • numbers: 5, 8.2, 99%, 20px $variables -
• containers for values • variable name define the purpose
of values • Five value types in Sass: • numbers: 5, 8.2, 99%, 20px • text strings: foo bar, “baz qux” $variables -
• containers for values • variable name define the purpose
of values • Five value types in Sass: • numbers: 5, 8.2, 99%, 20px • text strings: foo bar, “baz qux” • colors: #38e1b2, rgba(0, 128, 255, 0.3) $variables -
• containers for values • variable name define the purpose
of values • Five value types in Sass: • numbers: 5, 8.2, 99%, 20px • text strings: foo bar, “baz qux” • colors: #38e1b2, rgba(0, 128, 255, 0.3) • booleans: true or false $variables -
• containers for values • variable name define the purpose
of values • Five value types in Sass: • numbers: 5, 8.2, 99%, 20px • text strings: foo bar, “baz qux” • colors: #38e1b2, rgba(0, 128, 255, 0.3) • booleans: true or false • lists: 2px 10px 15px or Arial, Helvetica, Courier $variables -
_messaging.sass .flash-message position: relative margin: 0 auto 15px width: 435px
border-radius: 5px padding: 10px 50px 10px 15px color: white font-weight: bold .flash-info @extend .flash-message background: #a4a4a4 text-shadow: 0 -1px #838484 .flash-success @extend .flash-message background: #1b942a text-shadow: 0 -1px #1a7e1c .flash-error @extend .flash-message background: #ef9000 text-shadow: 0 -1px #e8541c li font-weight: normal .flash-icon display: block position: absolute top: 11px right: 12px -
_messaging.sass .flash-message position: relative margin: 0 auto 15px width: 435px
border-radius: 5px padding: 10px 50px 10px 15px color: white font-weight: bold .flash-icon display: block position: absolute top: 11px right: 12px .flash-info @extend .flash-message background: #a4a4a4 text-shadow: 0 -1px #838484 .flash-success @extend .flash-message background: #1b942a text-shadow: 0 -1px #1a7e1c .flash-error @extend .flash-message background: #ef9000 text-shadow: 0 -1px #e8541c li font-weight: normal -
_messaging.sass .flash-message position: relative margin: 0 auto 15px width: 435px
border-radius: 5px padding: 10px 50px 10px 15px color: white font-weight: bold .flash-icon display: block position: absolute top: 11px right: 12px .flash-info @extend .flash-message background: #a4a4a4 text-shadow: 0 -1px #838484 .flash-success @extend .flash-message background: #1b942a text-shadow: 0 -1px #1a7e1c .flash-error @extend .flash-message background: #ef9000 text-shadow: 0 -1px #e8541c li font-weight: normal -
_messaging.sass $flash-info-background: #a4a4a4 $flash-info-text-shadow: #838484 $flash-success-background: #1b942a $flash-success-text-shadow: #1a7e1c $flash-error-background:
#ef9000 $flash-error-text-shadow: #e8541c .flash-message position: relative margin: 0 auto 15px width: 435px border-radius: 5px padding: 10px 50px 10px 15px color: white font-weight: bold .flash-icon display: block position: absolute top: 11px right: 12px .flash-info @extend .flash-message background: #a4a4a4 text-shadow: 0 -1px #838484 .flash-success @extend .flash-message background: #1b942a text-shadow: 0 -1px #1a7e1c .flash-error @extend .flash-message background: #ef9000 text-shadow: 0 -1px #e8541c li font-weight: normal -
_messaging.sass $flash-info-background: #a4a4a4 $flash-info-text-shadow: #838484 $flash-success-background: #1b942a $flash-success-text-shadow: #1a7e1c $flash-error-background:
#ef9000 $flash-error-text-shadow: #e8541c .flash-message position: relative margin: 0 auto 15px width: 435px border-radius: 5px padding: 10px 50px 10px 15px color: white font-weight: bold .flash-icon display: block position: absolute top: 11px right: 12px .flash-info @extend .flash-message background: $flash-info-background text-shadow: 0 -1px $flash-info-text-shadow .flash-success @extend .flash-message background: $flash-success-background text-shadow: 0 -1px $flash-success-text-shadow .flash-error @extend .flash-message background: $flash-error-background text-shadow: 0 -1px $flash-error-text-shadow li font-weight: normal -
_messaging.sass $flash-info-background: #a4a4a4 $flash-info-text-shadow: #838484 $flash-success-background: #1b942a $flash-success-text-shadow: #1a7e1c $flash-error-background:
#ef9000 $flash-error-text-shadow: #e8541c .flash-message position: relative margin: 0 auto 15px width: 435px border-radius: 5px padding: 10px 50px 10px 15px color: white font-weight: bold .flash-icon display: block position: absolute top: 11px right: 12px .flash-info @extend .flash-message background: $flash-info-background text-shadow: 0 -1px $flash-info-text-shadow .flash-success @extend .flash-message background: $flash-success-background text-shadow: 0 -1px $flash-success-text-shadow .flash-error @extend .flash-message background: $flash-error-background text-shadow: 0 -1px $flash-error-text-shadow li font-weight: normal -
_messaging.sass .flash-message position: relative margin: 0 auto 15px width: 435px
border-radius: 5px padding: 10px 50px 10px 15px color: white font-weight: bold .flash-icon display: block position: absolute top: 11px right: 12px .flash-info @extend .flash-message background: $flash-info-background text-shadow: 0 -1px $flash-info-text-shadow .flash-success @extend .flash-message background: $flash-success-background text-shadow: 0 -1px $flash-success-text-shadow .flash-error @extend .flash-message background: $flash-error-background text-shadow: 0 -1px $flash-error-text-shadow li font-weight: normal -
_config.sass $flash-info-background: #a4a4a4 $flash-info-text-shadow: #838484 $flash-success-background: #1b942a $flash-success-text-shadow: #1a7e1c $flash-error-background:
#ef9000 $flash-error-text-shadow: #e8541c screen.sass @import compass/reset @import layout @import messaging -
_config.sass $flash-info-background: #a4a4a4 $flash-info-text-shadow: #838484 $flash-success-background: #1b942a $flash-success-text-shadow: #1a7e1c $flash-error-background:
#ef9000 $flash-error-text-shadow: #e8541c screen.sass @import compass/reset @import layout @import messaging @import config -
Just like in algebra class, show your work. • Replace
arbitrary numbers with calculations. Math -
Just like in algebra class, show your work. • Replace
arbitrary numbers with calculations. • Control your grid styles Math -
Just like in algebra class, show your work. • Replace
arbitrary numbers with calculations. • Control your grid styles • Document logic in your styles Math -
_messaging.sass .flash-message position: relative margin: 0 auto 15px width: 435px
border-radius: 5px padding: 10px 50px 10px 15px color: white font-weight: bold -
_messaging.sass .flash-message position: relative margin: 0 auto 15px width: 435px
border-radius: 5px padding: 10px 50px 10px 15px color: white font-weight: bold -
_messaging.sass $flash-message-width: 500px .flash-message position: relative width: 435px border-radius: 5px
padding: 10px 50px 10px 15px color: white font-weight: bold -
_messaging.sass $flash-message-width: 500px $flash-message-h-padding: 15px .flash-message position: relative width: 435px
border-radius: 5px padding: 10px 50px 10px 15px color: white font-weight: bold -
_messaging.sass $flash-message-width: 500px $flash-message-h-padding: 15px $flash-message-icon-padding: image-width("icon-info.png") .flash-message position: relative
width: 435px border-radius: 5px padding: 10px 50px 10px 15px color: white font-weight: bold -
_messaging.sass $flash-message-width: 500px $flash-message-h-padding: 15px $flash-message-icon-padding: image-width("icon-info.png") .flash-message position: relative
width: 435px border-radius: 5px padding: 10px 50px 10px 15px color: white font-weight: bold 35px -
_messaging.sass $flash-message-width: 500px $flash-message-h-padding: 15px $flash-message-icon-padding: image-width("icon-info.png") + $flash-message-h-padding .flash-message
position: relative width: 435px border-radius: 5px padding: 10px 50px 10px 15px color: white font-weight: bold -
_messaging.sass $flash-message-width: 500px $flash-message-h-padding: 15px $flash-message-icon-padding: image-width("icon-info.png") + $flash-message-h-padding .flash-message
position: relative width: 435px border-radius: 5px padding: 10px 50px 10px 15px color: white font-weight: bold -
_messaging.sass $flash-message-width: 500px $flash-message-h-padding: 15px $flash-message-icon-padding: image-width("icon-info.png") + $flash-message-h-padding .flash-message
position: relative width: 435px border-radius: 5px padding: 10px 50px 10px 15px color: white font-weight: bold -
_messaging.sass $flash-message-width: 500px $flash-message-h-padding: 15px $flash-message-icon-padding: image-width("icon-info.png") + 15px .flash-message
position: relative width: $flash-message-width - $flash-message-h-padding * 2 - $flash-message-icon-padding border-radius: 5px padding: 10px 50px 10px 15px color: white font-weight: bold -
_messaging.sass $flash-message-width: 500px $flash-message-h-padding: 15px $flash-message-icon-padding: image-width("icon-info.png") + 15px .flash-message
position: relative width: $flash-message-width - $flash-message-h-padding * 2 - $flash-message-icon-padding border-radius: 5px padding: 10px 50px 10px 15px color: white font-weight: bold -
_messaging.sass $flash-message-width: 500px $flash-message-h-padding: 15px $flash-message-icon-padding: image-width("icon-info.png") + 15px .flash-message
position: relative width: $flash-message-width - $flash-message-h-padding * 2 - $flash-message-icon-padding border-radius: 5px padding: 10px 50px 10px 15px color: white font-weight: bold -
_messaging.sass $flash-message-width: 500px $flash-message-h-padding: 15px $flash-message-icon-padding: image-width("icon-info.png") + 15px .flash-message
position: relative width: $flash-message-width - $flash-message-h-padding * 2 - $flash-message-icon-padding border-radius: 5px padding: 10px 50px 10px 15px color: white font-weight: bold -
_messaging.sass $flash-message-width: 500px $flash-message-h-padding: 15px $flash-message-icon-padding: image-width("icon-info.png") + 15px .flash-message
position: relative width: $flash-message-width - $flash-message-h-padding * 2 - $flash-message-icon-padding border-radius: 5px padding: 10px 50px 10px 15px color: white font-weight: bold -
_messaging.sass $flash-message-width: 500px $flash-message-h-padding: 15px $flash-message-icon-padding: image-width("icon-info.png") + 15px .flash-message
position: relative width: $flash-message-width - $flash-message-h-padding * 2 - $flash-message-icon-padding border-radius: 5px padding: 10px $flash-message-h-padding + $flash-message-icon-padding 10px $flash-message-h-padding color: white font-weight: bold -
_messaging.sass $flash-message-width: 500px $flash-message-h-padding: 15px $flash-message-icon-padding: image-width("icon-info.png") + 15px .flash-message
position: relative width: $flash-message-width - $flash-message-h-padding * 2 - $flash-message-icon-padding border-radius: 5px padding: 10px $flash-message-h-padding + $flash-message-icon-padding 10px $flash-message-h-padding color: white font-weight: bold -
_messaging.sass $flash-message-width: 500px $flash-message-h-padding: 15px $flash-message-icon-padding: image-width("icon-info.png") + 15px .flash-message
position: relative width: $flash-message-width - $flash-message-h-padding * 2 - $flash-message-icon-padding border-radius: 5px padding: 10px $flash-message-h-padding + $flash-message-icon-padding 10px $flash-message-h-padding color: white font-weight: bold -
_messaging.sass $flash-message-width: 500px $flash-message-h-padding: 15px $flash-message-icon-padding: image-width("icon-info.png") + 15px .flash-message
position: relative width: $flash-message-width - $flash-message-h-padding * 2 - $flash-message-icon-padding border-radius: 5px padding: 10px $flash-message-h-padding + $flash-message-icon-padding 10px $flash-message-h-padding color: white font-weight: bold -
_messaging.sass .flash-info @extend .flash-message background: $flash-info-background text-shadow: 0 -1px $flash-info-text-shadow
.flash-success @extend .flash-message background: $flash-success-background text-shadow: 0 -1px $flash-success-text-shadow .flash-error @extend .flash-message background: $flash-error-background text-shadow: 0 -1px $flash-error-text-shadow li font-weight: normal -
_messaging.sass .flash-info @extend .flash-message background: $flash-info-background text-shadow: 0 -1px $flash-info-text-shadow
.flash-success @extend .flash-message background: $flash-success-background text-shadow: 0 -1px $flash-success-text-shadow .flash-error @extend .flash-message background: $flash-error-background text-shadow: 0 -1px $flash-error-text-shadow li font-weight: normal see -
_messaging.sass .flash-info @extend .flash-message background: $flash-info-background text-shadow: 0 -1px $flash-info-text-shadow
.flash-success @extend .flash-message background: $flash-success-background text-shadow: 0 -1px $flash-success-text-shadow .flash-error @extend .flash-message background: $flash-error-background text-shadow: 0 -1px $flash-error-text-shadow li font-weight: normal see the -
_messaging.sass .flash-info @extend .flash-message background: $flash-info-background text-shadow: 0 -1px $flash-info-text-shadow
.flash-success @extend .flash-message background: $flash-success-background text-shadow: 0 -1px $flash-success-text-shadow .flash-error @extend .flash-message background: $flash-error-background text-shadow: 0 -1px $flash-error-text-shadow li font-weight: normal see the pattern? -
_messaging.sass @mixin flash-message($type, $background, $text-shadow) .flash-#{$type} @extend .flash-message background: $background
text-shadow: 0 -1px $text-shadow @if $type == error li font-weight: normal -
_messaging.sass @mixin flash-message($type, $background, $text-shadow) .flash-#{$type} @extend .flash-message background: $background
text-shadow: 0 -1px $text-shadow @if $type == error li font-weight: normal -
_messaging.sass @mixin flash-message($type, $background, $text-shadow) .flash-#{$type} @extend .flash-message background: $background
text-shadow: 0 -1px $text-shadow @if $type == error li font-weight: normal -
_messaging.sass @include flash-message(info, $flash-info-background, $flash-info-text-shadow) @include flash-message(success, $flash-success-background, $flash-success-text-shadow) @include
flash-message(error, $flash-error-background, $flash-error-text-shadow) @mixin flash-message($type, $background, $text-shadow) .flash-#{$type} @extend .flash-message background: $background text-shadow: 0 -1px $text-shadow @if $type == error li font-weight: normal -
_messaging.sass +flash-message(info, $flash-info-background, $flash-info-text-shadow) +flash-message(success, $flash-success-background, $flash-success-text-shadow) +flash-message(error, $flash-error-background, $flash-error-text-shadow)
=flash-message($type, $background, $text-shadow) .flash-#{$type} @extend .flash-message background: $background text-shadow: 0 -1px $text-shadow @if $type == error li font-weight: normal -
_messaging.sass .icon-sprite display: block position: absolute top: 11px right: 12px
@import "icon/*.png" +all-icon-sprites -
_messaging.sass .icon-sprite display: block position: absolute top: 11px right: 12px
@import "icon/*.png" +all-icon-sprites $icon-sprite-dimensions: true -
_messaging.sass .icon-sprite display: block position: absolute top: 11px right: 12px
@import "icon/*.png" +all-icon-sprites $icon-sprite-dimensions: true -
_messaging.sass .icon-sprite display: block position: absolute top: 11px right: 12px
@import "icon/*.png" +all-icon-sprites $icon-sprite-dimensions: true Compass config file -
_messaging.sass .icon-sprite display: block position: absolute top: 11px right: 12px
@import "icon/*.png" +all-icon-sprites $icon-sprite-dimensions: true config.rb http_path = "/" css_dir = "stylesheets" sass_dir = "sass" images_dir = "images" javascripts_dir = "javascripts" output_style = :nested relative_assets = true line_comments = false Compass config file -
_messaging.sass .icon-sprite display: block position: absolute top: 11px right: 12px
@import "icon/*.png" +all-icon-sprites $icon-sprite-dimensions: true config.rb http_path = "/" css_dir = "stylesheets" sass_dir = "sass" images_dir = "images" javascripts_dir = "javascripts" output_style = :nested relative_assets = true line_comments = false Compass config file -
_messaging.sass .icon-sprite display: block position: absolute top: 11px right: 12px
@import "icon/*.png" +all-icon-sprites $icon-sprite-dimensions: true Compass config file -
_messaging.sass .icon-sprite display: block position: absolute top: 11px right: 12px
@import "icon/*.png" +all-icon-sprites $icon-sprite-dimensions: true generated sprite icon-s5c33447329.png Compass config file -
Compiled sprite CSS .icon-sprite, .icon-error, .icon-info, .icon-success { display: block;
position: absolute; top: 11px; right: 12px; } .icon-sprite, .icon-error, .icon-info, .icon-success { background: url('../images/icon-sa3bc8b9105.png') no-repeat; } -
Compiled sprite CSS .icon-sprite, .icon-error, .icon-info, .icon-success { display: block;
position: absolute; top: 11px; right: 12px; } .icon-sprite, .icon-error, .icon-info, .icon-success { background: url('../images/icon-sa3bc8b9105.png') no-repeat; } -
Compiled sprite CSS .icon-sprite, .icon-error, .icon-info, .icon-success { display: block;
position: absolute; top: 11px; right: 12px; } .icon-sprite, .icon-error, .icon-info, .icon-success { background: url('../images/icon-sa3bc8b9105.png') no-repeat; } -
Compiled sprite CSS .icon-sprite, .icon-error, .icon-info, .icon-success { display: block;
position: absolute; top: 11px; right: 12px; } .icon-sprite, .icon-error, .icon-info, .icon-success { background: url('../images/icon-sa3bc8b9105.png') no-repeat; } -
Compiled sprite CSS .icon-sprite, .icon-error, .icon-info, .icon-success { display: block;
position: absolute; top: 11px; right: 12px; } .icon-sprite, .icon-error, .icon-info, .icon-success { background: url('../images/icon-sa3bc8b9105.png') no-repeat; } .icon-error { background-position: 0 0; height: 19px; width: 20px; } .icon-info { background-position: 0 -19px; height: 21px; width: 20px; } .icon-success { background-position: 0 -40px; height: 21px; width: 20px; } -
Compiled sprite CSS .icon-sprite, .icon-error, .icon-info, .icon-success { display: block;
position: absolute; top: 11px; right: 12px; } .icon-sprite, .icon-error, .icon-info, .icon-success { background: url('../images/icon-sa3bc8b9105.png') no-repeat; } .icon-error { background-position: 0 0; height: 19px; width: 20px; } .icon-info { background-position: 0 -19px; height: 21px; width: 20px; } .icon-success { background-position: 0 -40px; height: 21px; width: 20px; } -
Compiled sprite CSS .icon-sprite, .icon-error, .icon-info, .icon-success { display: block;
position: absolute; top: 11px; right: 12px; } .icon-sprite, .icon-error, .icon-info, .icon-success { background: url('../images/icon-sa3bc8b9105.png') no-repeat; } .icon-error { background-position: 0 0; height: 19px; width: 20px; } .icon-info { background-position: 0 -19px; height: 21px; width: 20px; } .icon-success { background-position: 0 -40px; height: 21px; width: 20px; } -
messaging.html <div class="flash-info"> <img src="images/icon-info.png" alt="info icon" class="flash-icon"> <p>You have
mail.</p> </div> <div class="flash-success"> <img src="images/icon-success.png" alt="success icon" class="flash-icon"> <p>Settings updated!</p> </div> <div class="flash-error"> <img src="images/icon-error.png" alt="error icon" class="flash-icon"> <p>Please fix the following errors:</p> <ul> <li>Username requires more pizazz.</li> <li>Password is too easy to hack.</li> <li>You must be at least this tall to ride this ride.</li> </ul> </div> -
messaging.html <div class="flash-info"> <img src="images/icon-info.png" alt="info icon" class="flash-icon"> <p>You have
mail.</p> </div> <div class="flash-success"> <img src="images/icon-success.png" alt="success icon" class="flash-icon"> <p>Settings updated!</p> </div> <div class="flash-error"> <img src="images/icon-error.png" alt="error icon" class="flash-icon"> <p>Please fix the following errors:</p> <ul> <li>Username requires more pizazz.</li> <li>Password is too easy to hack.</li> <li>You must be at least this tall to ride this ride.</li> </ul> </div> -
messaging.html <div class="flash-info"> <div class="icon-info"></div> <p>You have mail.</p> </div> <div
class="flash-success"> <div class="icon-success"></div> <p>Settings updated!</p> </div> <div class="flash-error"> <div class="icon-error"></div> <p>Please fix the following errors:</p> <ul> <li>Username requires more pizazz.</li> <li>Password is too easy to hack.</li> <li>You must be at least this tall to ride this ride.</li> </ul> </div> -
messaging.html <div class="flash-info"> <div class="icon-info"></div> <p>You have mail.</p> </div> <div
class="flash-success"> <div class="icon-success"></div> <p>Settings updated!</p> </div> <div class="flash-error"> <div class="icon-error"></div> <p>Please fix the following errors:</p> <ul> <li>Username requires more pizazz.</li> <li>Password is too easy to hack.</li> <li>You must be at least this tall to ride this ride.</li> </ul> </div> -
Inline images ul margin-left: 20px $bullet-image: "bullet.png" list-style-image: inline-image($bullet-image, image/png)
ul { list-style-image: url('data:image/ png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAJCAYAAAAPU20uAAAAT0lEQVR42r3KsQ2AMAxE0ZuA UdIwAPOwldfJJiAxgN344muDQslJv/EzSB5V53tdhsy8uJgM5Pf+eHD3e4UymNkZEc +MuslQ26pW7VNNNgBdFvofIZ4THgAAAABJRU5ErkJggg=='); margin-left: 20px; } -
border-radius CSS .flash-message { -moz-border-radius: 5px; -webkit-border-radius: 5px; -o-border-radius: 5px;
-ms-border-radius: 5px; -khtml-border-radius: 5px; border-radius: 5px; } -
@import compass/css3 .flash-message +border-radius(5px) border-radius Sass CSS .flash-message { -moz-border-radius:
5px; -webkit-border-radius: 5px; -o-border-radius: 5px; -ms-border-radius: 5px; -khtml-border-radius: 5px; border-radius: 5px; } -
box-shadow .flash-message { -moz-box-shadow: 0 0 3px rgba(0, 0, 0,
0.12) inset, 0 1px 0 rgba(0, 0, 0, 0.05) inset; -webkit-box-shadow: 0 0 3px rgba(0, 0, 0, 0.12) inset, 0 1px 0 rgba(0, 0, 0, 0.05) inset; -o-box-shadow: 0 0 3px rgba(0, 0, 0, 0.12) inset, 0 1px 0 rgba(0, 0, 0, 0.05) inset; box-shadow: 0 0 3px rgba(0, 0, 0, 0.12) inset, 0 1px 0 rgba(0, 0, 0, 0.05) inset; box-shadow: 0 0 3px rgba(0, 0, 0, 0.12) inset, 0 1px 0 rgba(0, 0, 0, 0.05) inset; } CSS -
box-shadow .flash-message $inner-shadow: 0 0 3px rgba(0, 0, 0, .12)
inset $inner-shadow-top: 0 1px 0 rgba(0, 0, 0, .05) inset +box-shadow($inner-shadow, $inner-shadow-top) .flash-message { -moz-box-shadow: 0 0 3px rgba(0, 0, 0, 0.12) inset, 0 1px 0 rgba(0, 0, 0, 0.05) inset; -webkit-box-shadow: 0 0 3px rgba(0, 0, 0, 0.12) inset, 0 1px 0 rgba(0, 0, 0, 0.05) inset; -o-box-shadow: 0 0 3px rgba(0, 0, 0, 0.12) inset, 0 1px 0 rgba(0, 0, 0, 0.05) inset; box-shadow: 0 0 3px rgba(0, 0, 0, 0.12) inset, 0 1px 0 rgba(0, 0, 0, 0.05) inset; box-shadow: 0 0 3px rgba(0, 0, 0, 0.12) inset, 0 1px 0 rgba(0, 0, 0, 0.05) inset; } Sass CSS -
box-shadow .flash-message $inner-shadow: 0 0 3px rgba(0, 0, 0, .12)
inset $inner-shadow-top: 0 1px 0 rgba(0, 0, 0, .05) inset +box-shadow($inner-shadow, $inner-shadow-top) .flash-message { -moz-box-shadow: 0 0 3px rgba(0, 0, 0, 0.12) inset, 0 1px 0 rgba(0, 0, 0, 0.05) inset; -webkit-box-shadow: 0 0 3px rgba(0, 0, 0, 0.12) inset, 0 1px 0 rgba(0, 0, 0, 0.05) inset; -o-box-shadow: 0 0 3px rgba(0, 0, 0, 0.12) inset, 0 1px 0 rgba(0, 0, 0, 0.05) inset; box-shadow: 0 0 3px rgba(0, 0, 0, 0.12) inset, 0 1px 0 rgba(0, 0, 0, 0.05) inset; box-shadow: 0 0 3px rgba(0, 0, 0, 0.12) inset, 0 1px 0 rgba(0, 0, 0, 0.05) inset; } Sass CSS -
div color: black .foo color: black &.bar color: black &:hover
color: black .ie7 & color: black .parent & .child color: black Sass -
div color: black .foo color: black &.bar color: black &:hover
color: black .ie7 & color: black .parent & .child color: black div { color: black; } div .foo { color: black; } div.bar { color: black; } div:hover { color: black; } .ie7 div { color: black; } .parent div .child { color: black; } Sass CSS -
div color: black .foo color: black &.bar color: black &:hover
color: black .ie7 & color: black .parent & .child color: black div { color: black; } div .foo { color: black; } div.bar { color: black; } div:hover { color: black; } .ie7 div { color: black; } .parent div .child { color: black; } Sass CSS -
div color: black .foo color: black &.bar color: black &:hover
color: black .ie7 & color: black .parent & .child color: black div { color: black; } div .foo { color: black; } div.bar { color: black; } div:hover { color: black; } .ie7 div { color: black; } .parent div .child { color: black; } Sass CSS -
div color: black .foo color: black &.bar color: black &:hover
color: black .ie7 & color: black .parent & .child color: black div { color: black; } div .foo { color: black; } div.bar { color: black; } div:hover { color: black; } .ie7 div { color: black; } .parent div .child { color: black; } Sass CSS -
div color: black .foo color: black &.bar color: black &:hover
color: black .ie7 & color: black .parent & .child color: black div { color: black; } div .foo { color: black; } div.bar { color: black; } div:hover { color: black; } .ie7 div { color: black; } .parent div .child { color: black; } Sass CSS -
div color: black .foo color: black &.bar color: black &:hover
color: black .ie7 & color: black .parent & .child color: black div { color: black; } div .foo { color: black; } div.bar { color: black; } div:hover { color: black; } .ie7 div { color: black; } .parent div .child { color: black; } Sass CSS -
.flash-message a text-decoration: none color: $link-color &:visited color: $link-color &:hover
color: $link-hover-color text-decoration: underline &:active color: $link-active-color Styling links -
.flash-message a text-decoration: none color: $link-color &:visited color: $link-color &:hover
color: $link-hover-color text-decoration: underline &:active color: $link-active-color Styling links $link-color: #89F2FF $link-hover-color: darken($link-color, 20%) $link-active-color: complement($link-color) -
.flash-message a text-decoration: none color: $link-color &:visited color: $link-color &:hover
color: $link-hover-color text-decoration: underline &:active color: $link-active-color Styling links .flash-message a { text-decoration: none; color: #89f2ff; } .flash-message a:visited { color: #89f2ff; } .flash-message a:hover { color: #23e7ff; text-decoration: underline; } .flash-message a:active { color: #ff9689; } $link-color: #89F2FF $link-hover-color: darken($link-color, 20%) $link-active-color: complement($link-color) Compiled CSS -
IE fixes .flash-message background: #f9f9f9 image-url("images/page.png") +box-shadow(0 0 0 3px
rgba(black, .5)) .ie & +box-shadow(0 0 0 1px rgba(black, .2)) // adjust box-shadow .ie7 & border: 1px solid #e0e0e0 // use border in place of box-shadow background: #f9f9f9 // just background color -
IE fixes .flash-message { background: #f9f9f9 url('../images/icon/info.png?1315463945'); -moz-box-shadow: 0 0
0 3px rgba(0, 0, 0, 0.5); -webkit-box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.5); -o-box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.5); box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.5); } .ie .flash-message { -moz-box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.2); -webkit-box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.2); -o-box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.2); box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.2); } .ie7 .flash-message { border: 1px solid #e0e0e0; background: #f9f9f9; } .flash-message background: #f9f9f9 image-url("images/page.png") +box-shadow(0 0 0 3px rgba(black, .5)) .ie & +box-shadow(0 0 0 1px rgba(black, .2)) // adjust box-shadow .ie7 & border: 1px solid #e0e0e0 // use border in place of box-shadow background: #f9f9f9 // just background color Compiled CSS -
Improper @mixin use can cause redundant CSS declarations. Abusing @extend
and deep nesting will lead to needlessly long selector strings.