Syntactically Awesome Stylesheets
CSS
article {
margin: 10px;
p {
text-align: justify;
a.special {
color: #855;
}
}
}
article {
margin: 10px;
}
article p {
text-align: justify;
}
article p a.special {
color: #855;
}
a.btn {
color: #555;
&:hover, &:active {
text-decoration: underline;
}
&.btn-primary {
color: red;
}
}
a.btn {
color: #555;
}
a.btn:hover, a.btn:active {
text-decoration: underline;
}
a.btn.btn-primary {
color: red;
}
<html class="js no-touch postmessage history multiplebgs boxshadow opacity cssanimations csscolumns cssgradients csstransforms csstransitions .......">
.fancy {
background-image: linear-gradient(top center, #555, #888);
.no-cssgradients & {
background-color: #555;
}
}
.fancy {
background-image: linear-gradient(top center, #555555, #888888);
}
.no-cssgradients .fancy {
background-color: #555;
}
$primary-color: #ff0000;
// oder $primary-color: red;
h2 {
color: $primary-color;
}
h1 {
color: invert($primary-color);
}
h2 {
color: red;
}
h1 {
color: cyan;
}
$width: 800px;
$margin: 20px;
$real-width: $width - 2 * $margin;
.container {
width: $real-width;
margin: $margin;
.half {
width: $real-width / 2;
}
}
.container {
width: 760px;
margin: 20px;
}
.container .half {
width: 380px;
}
$main: #666;
$darker: darken($main, 10%);
$lighter: lighten($main, 10%);
h1 { color: $main; }
h2 { color: $darker; }
h3 { color: $lighter; }
h1 {
color: #666666;
}
h2 {
color: #4d4d4d;
}
h3 {
color: gray;
}
@mixin border-radius( $amount) {
border-radius: $amount ;
-webkit-border-radius: $amount ;
-moz-border-radius: $amount ;
}
article {
@include border-radius(5px)
}
article {
border-radius: 5px;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
}
@mixin vendor-prefix($name, $argument) {
#{$name}: $argument;
-webkit-#{$name}: $argument;
-ms-#{$name}: $argument;
-moz-#{$name}: $argument;
-o-#{$name}: $argument;
}
p {
@include vendor-prefix(hyphens, auto);
@include vendor-prefix(border-radius, 5px);
}
p {
hyphens: auto;
-webkit-hyphens: auto;
-ms-hyphens: auto;
-moz-hyphens: auto;
-o-hyphens: auto;
border-radius: 5px;
-webkit-border-radius: 5px;
-ms-border-radius: 5px;
-moz-border-radius: 5px;
-o-border-radius: 5px;
}
@for $i from 1 through 12 {
.tile#{$i} {
width: $i * 77px;
height: $i * 77px;
}
}
.tile1 { width: 77px; height: 77px; }
.tile2 { width: 154px; height: 154px; }
.tile3 { width: 231px; height: 231px; }
.tile4 { width: 308px; height: 308px; }
.tile5 { width: 385px; height: 385px; }
.tile6 { width: 462px; height: 462px; }
.tile7 { width: 539px; height: 539px; }
.tile8 { width: 616px; height: 616px; }
.tile9 { width: 693px; height: 693px; }
.tile10 { width: 770px; height: 770px; }
.tile11 { width: 847px; height: 847px; }
.tile12 { width: 924px; height: 924px; }
@mixin hyphens($value: "manual") {
@each $prefix in -webkit-, -moz-, -o-, "" {
#{$prefix}hyphens: $value;
}
}
p {
text-align: justify;
@include hyphens(auto);
}
p {
text-align: justify;
-webkit-hyphens: auto;
-moz-hyphens: auto;
-o-hyphens: auto;
hyphens: auto;
}
@mixin button($color) {
background: $color;
@if lightness($color) > 50 {
color: black;
} @else {
color: white;
}
}
a.button-dark { @include button(#444) }
a.button-light { @include button(#999) }
a.button-dark {
background: #444444;
color: white;
}
a.button-light {
background: #999999;
color: black;
}
@import "core";
@import "typography" , "grid";
@import "styles/*";
@import "**/*;"
@media screen and (min-width: 320px) {
@import "phone";
}
body.admin {
@import "admin";
}
@media screen and (min-width: 320px) {
// inhalt von phone.css
.sidebar { display: none; }
}
body.admin {
// user.css
a.logout { color: blue; }
}
@media screen and (min-width: 320px) {
.sidebar {
display: none;
}
}
body.admin a.logout {
color: blue;
}
$ gem install sass
$ sass --watch screen.scss
>>> Sass is watching for changes. Press Ctrl-C to stop
>>> Change detected to: ./screen.scss
overwrite ./screen.css
.highlight { background: #2B2B2B}
.highlight .hll { background-color: #ffffcc }
.highlight .c { color: #BC9458}
.highlight {
background: #2B2B2B;
.hll {
background-color: #ffffcc;
}
.c {
color: #BC9458;
}
}
gem install compass
compass create myproject
compass watch
http_path = "/"
css_dir = "stylesheets"
sass_dir = "sass"
images_dir = "images"
javascripts_dir = "javascripts"
output_style = :expanded # or :nested or :compact or :compressed
line_comments = false
# Plugins!
require 'ninesixty'
require 'susy'
/* line 107, stylesheets/_mixins.css.sass */
label {
display: block;
}
@import "compass/css3/transform";
@import "compass/css3/images";
a {
@include transform( scale(1.2) );
@include background-image(linear-gradient(left top, white, #dddddd));
}
a {
-webkit-transform: scale(1.2);
-moz-transform: scale(1.2);
-ms-transform: scale(1.2);
-o-transform: scale(1.2);
transform: scale(1.2);
background-image: -webkit-gradient(linear, 0% 0%, 100% 100%, color-stop(0%, #ffffff), color-stop(100%, #dddddd));
background-image: -webkit-linear-gradient(left top, #ffffff, #dddddd);
background-image: -moz-linear-gradient(left top, #ffffff, #dddddd);
background-image: -o-linear-gradient(left top, #ffffff, #dddddd);
background-image: linear-gradient(left top, #ffffff, #dddddd);
}
Weil:
@import "compass";
@import "icons/*.png";
@include all-icons-sprites;
.icons-sprite, .icons-glyphicons_000_glass, .icons-glyphicons_001_leaf, .icons-glyphicons_002_dog, .icons-glyphicons_003_user, .icons-glyphicons_004_girl, .icons-glyphicons_005_car, .icons-glyphicons_006_user_add, .icons-glyphicons_007_user_remove, .icons-glyphicons_008_film, .icons-glyphicons_009_magic { background: url('/images/icons-s824d25e81f.png') no-repeat; }
.icons-glyphicons_000_glass { background-position: 0 -74px; }
.icons-glyphicons_001_leaf { background-position: 0 0; }
.icons-glyphicons_002_dog { background-position: 0 -49px; }
.icons-glyphicons_003_user { background-position: 0 -186px; }
.icons-glyphicons_004_girl { background-position: 0 -120px; }
.icons-glyphicons_005_car { background-position: 0 -98px; }
.icons-glyphicons_006_user_add { background-position: 0 -142px; }
.icons-glyphicons_007_user_remove { background-position: 0 -164px; }
.icons-glyphicons_008_film { background-position: 0 -208px; }
.icons-glyphicons_009_magic { background-position: 0 -25px; }
compass validate .
github.com/chriseppstein/compass/wiki/Compass-Plugins
Sass:
article {
margin-bottom: 2em;
.entry-content {
border-top: 1px solid #eee;
@include box-shadow(2px, black)
}
}
article
margin-bottom: 2em
.entry-content
border-top: 1px solid #eee
+box-shadow(2px, black)
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem "compass-rails"
end
rm app/assets/stylesheets/application.css
vim app/assets/stylesheets/application.css.scss
@import "jquery_ui";
@import "twitter/bootstrap;
body.user {
@import "user/**/*";
}
# layouts/application.html.erb
<% if logged_in? %>
<%= stylesheet_include_tag "user" %>
<% end %>
# config/application.rb
config.assets.precompile += [ "user.css" ]
config.assets.digest = true
)
.handle {
background: image-url("handle.png");
}
.handle {
background-image:url(/assets/handle-e0da531f6d0f44ecd2d6efde3c3fd75d.png)
}
@import "compass/css3/transform";
# Gemfile
group :assets do
gem "sassy-buttons"
end
bundle exec compass install sassy-buttons
# config/application.rb
config.compass.require "sassy-buttons"
@import "sassy-buttons";
a.button {
@include sassy-button("shiny", 15px, 26px, #ffd71a, #ffaa1a);
}
Scss
@import "other.css";
$mainColor: #0982c1;
a {
img {
border-color: $mainColor;
}
}
Less
@import "other.css";
@mainColor: #0982c1;
a {
img {
border-color: @mainColor;
}
}
Rewrite in C
powered by Reveal.js