The CSS revolution
Modern Ways of Frontend Development
Jan Krutisch for Railswaycon 2012
Made with showoff and <3
z, ? | toggle help (this) |
space, → | next slide |
shift-space, ← | previous slide |
d | toggle debug mode |
## <ret> | go to slide # |
c, t | table of contents (vi) |
f | toggle footer |
r | reload slides |
n | toggle notes |
p | run preshow |
P | toggle pause |
Jan Krutisch for Railswaycon 2012
Made with showoff and <3
/halfbyte
(they're hiring. yep.)
Concepts that make Rails great, Technologies that bring these concepts to CSS development and Possibilities opened up because of these
i = 1
class Book < ActiveRecord::Base
end
class Book
include ActiveModel::Validations
end
$ wget http://download.cssgrid.net/1140_CssGrid_2.zip
$ unzip 1140_CssGrid_2.zip
$ cp -r 1140_CssGrid_2/css/* dingens/public/stylesheets/
$ cp -r 1140_CssGrid_2/js/* dingens/public/javascripts/
$ rails g controller foos index
$ rake db:migrate
$ cap deploy
.foo
.bar
.baz
font-weight: black
.two
font-weight: 100
.foo {
.bar {
.baz {
font-weight: black;
}
.two {
font-weight: 100;
}
}
}
.foo {
.bar {
.baz {
font-weight: black;
}
.two {
font-weight: 100;
}
}
}
.foo .bar .baz {
font-weight: black;
}
.foo .bar .two {
font-weight: 100;
}
$width: 5em;
#main {
width: $width;
}
$width: 5em;
$margin: 2em;
#foo {
width: $width + $margin;
}
NXT: css
.foo {
width: 7em;
}
.foo {
color: rbg(255,0,0) + rgb(0,255,0);
}
.foo {
color: rgb(255,255,0);
}
.foo {
color: darken(#fff, 10%);
}
.foo {
color: #e6e6e6;
}
.foo {
color: transparentize(#fff, 0.5);
}
.foo {
color: rgba(255, 255, 255, 0.5);
}
.foo {
font-family: sans + "-serif";
}
.foo {
font-family: sans-serif;
}
@mixin simpleborder {
border: 1px solid black;
}
.foo {
@include simpleborder;
}
.foo {
border: 1px solid black;
}
@mixin stdborder($width: 1px) {
border: $width solid black;
}
.foo {
@include stdborder(2px);
}
.foo {
border: 2px solid black;
}
.error {
color: red;
}
.seriousError {
@extend .error;
font-weight: bold;
}
.error, .seriousError {
color: red;
}
.seriousError {
font-weight: bold;
}
.error.validation {
color: yellow;
}
.error, .seriousError {
color: red;
}
.error.validation,
.seriousError.validation {
color: yellow;
}
.seriousError {
font-weight: bold;
}
p {
@if 1 + 1 == 2 { border: 1px solid; }
@if 5 < 3 { border: 2px dotted; }
}
@for $i from 1 through 3 {
.item-#{$i} { width: 2em * $i; }
}
#main {
color: #fff;
background-color: #000; }
#main p {
width: 10em; }
.huge {
font-size: 10em;
font-weight: bold;
text-decoration: underline; }
#main {
color: #fff;
background-color: #000;
}
#main p {
width: 10em;
}
.huge {
font-size: 10em;
font-weight: bold;
text-decoration: underline;
}
#main { color: #fff; background-color: #000; }
#main p { width: 10em; }
.huge { font-size: 10em; font-weight: bold; text-decoration: underline; }
#main{color:#fff;background-color:#000}#main p{width:10em}.huge{font-size:10em;font-weight:bold;text-decoration:underline}
/public/stylesheets/foo.sass
->
/public/stylesheets/compiled/foo.css
require 'compass'
Compass::Frameworks.register(
"eleven40",
:path => "#{File.dirname(__FILE__)}/.."
)
gem 'compass'
gem 'eleven40'
@import "eleven40";
.container {
@include eleven40-container;
}
// [...]
.sidebar {
@include eleven40-fourcol;
}
.container {
padding-left: 20px;
padding-right: 20px;
}
.sidebar {
width: 30.8%;
margin-right: 3.8%;
float: left;
}
/app/stylesheets/foo.scss
->
/public/stylesheets/foo.css
/app/assets/stylesheets/
/app/assets/stylesheets/
/app/assets/javascripts/
/app/assets/images/
/*
*= require_self
*= require 'foo'
*= require_tree .
*/
$ rake assets:precompile
/app/assets/stylesheets/application.css
->
/public/assets/application-10227...ad1.css
app/assets/*
lib/assets/* # TODO: Test
vendor/assets/*
$box-background: #ccc;
$box-color: #fff;
@import "compass/css3";
.example {
@include box-shadow(rgba(0,0,0,0.5) 2px 2px 5px);
@include border-radius(5px);
}
.example {
-moz-box-shadow: rgba(0, 0, 0, 0.5) 2px 2px 5px;
-webkit-box-shadow: rgba(0, 0, 0, 0.5) 2px 2px 5px;
-o-box-shadow: rgba(0, 0, 0, 0.5) 2px 2px 5px;
box-shadow: rgba(0, 0, 0, 0.5) 2px 2px 5px;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
-o-border-radius: 5px;
-ms-border-radius: 5px;
-khtml-border-radius: 5px;
border-radius: 5px;
}
gem "sencha-touch"
Ask for sprite sheet knowledge
app/assets/images/icons/
save.png
print.png
email.png
@import "icons/*.png";
@include all-icons-sprites;
ONE image!
.icons-sprite, .icons-email, .icons-print, .icons-save {
background: url(/assets/icons-sb42720438c.png) no-repeat;
}
.icons-email {
background-position: 0 -24px;
}
.icons-print {
background-position: 0 -48px;
}
.icons-save {
background-position: 0 0;
}
<div class="icons-save"></div>
$ compass watch
I hope I was able to show you that...
...are Important Concepts of modern Web software development and that
are technologies that allow to use these concepts to bring...
CSS to a whole...
and give you a whole lot of new possibilities to do
In the frontend field. Thank you.