dotCSS

dotCSS 2016 - Summary

Moving the CSS styles forward

Note

This summary includes what I found more relevant for my current work at Ebury.

All the talks were awesome thanks to the great speakers.

In case you miss any talk or if you want to extend this summary, you can watch all the talks on the dot post.

Lea Verou

CSS variables

Speaker: Lea Verou

Say goodbye to multiple CSS files for a branding solution

CSS variables can be defined using the --color property

We can define them globally using the :root selector


            :root {
  --color: red;
}

.example-1 {
  background-color: var(--color);
}

.example-2 {
  color: var(--color);
}

.example-3 {
  border: 1px solid var(--color);
}
            

              
foo
bar
baz
foo
bar
baz

It is possible to modify the value of the variable in two ways

  • Including a CSS file that overrides it
    
                    :root {
      --color: green;
    }
                    
  • Updating the value from Javascript
    
                      document.querySelector(':root').style.setProperty('--color', 'green');
                    
foo
bar
baz

It's also a good way for separating the view from the controller

When writing CSS code we don't need to worry about how a variable is calculated

Example

We want to display a progress bar that indicates how much a user has scrolled down

HTML and CSS


              
Lorem ipsum dolor sit amet...

              .progress-bar {
  height: 5px;
  width: calc(var(--progress) * 1%);
  background-color: red;
  display: block;
}

.text {
  max-height: 50vh;
  overflow: auto;
}
            

Javascript


              $('.text').scroll(e => {
  let element = e.target;
  let maxScroll = element.scrollHeight - element.clientHeight;
  let currentScroll = element.scrollTop;
  let percentageScroll = currentScroll * 100 / maxScroll;
  document.querySelector('.progress-bar').style.setProperty('--progress', percentageScroll);
});
            

Result

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec aliquam arcu fringilla molestie iaculis. Ut vehicula nunc ex, ut rutrum dui tincidunt eget. Praesent eu volutpat dui. Morbi ante justo, ullamcorper et porttitor quis, aliquet sit amet libero. Sed id orci ultricies arcu viverra euismod. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum quis risus a urna aliquet molestie. Nam cursus laoreet neque sit amet sagittis. Donec non nulla in eros pellentesque scelerisque quis ac mi. Proin dignissim auctor orci, vitae pharetra enim scelerisque ac. In volutpat non nunc quis elementum. Aliquam varius, quam quis blandit aliquam, ipsum urna vulputate diam, vel gravida nibh velit mattis lacus. Aliquam aliquam scelerisque pellentesque.

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec aliquam arcu fringilla molestie iaculis. Ut vehicula nunc ex, ut rutrum dui tincidunt eget. Praesent eu volutpat dui. Morbi ante justo, ullamcorper et porttitor quis, aliquet sit amet libero. Sed id orci ultricies arcu viverra euismod. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum quis risus a urna aliquet molestie. Nam cursus laoreet neque sit amet sagittis. Donec non nulla in eros pellentesque scelerisque quis ac mi. Proin dignissim auctor orci, vitae pharetra enim scelerisque ac. In volutpat non nunc quis elementum. Aliquam varius, quam quis blandit aliquam, ipsum urna vulputate diam, vel gravida nibh velit mattis lacus. Aliquam aliquam scelerisque pellentesque.

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec aliquam arcu fringilla molestie iaculis. Ut vehicula nunc ex, ut rutrum dui tincidunt eget. Praesent eu volutpat dui. Morbi ante justo, ullamcorper et porttitor quis, aliquet sit amet libero. Sed id orci ultricies arcu viverra euismod. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum quis risus a urna aliquet molestie. Nam cursus laoreet neque sit amet sagittis. Donec non nulla in eros pellentesque scelerisque quis ac mi. Proin dignissim auctor orci, vitae pharetra enim scelerisque ac. In volutpat non nunc quis elementum. Aliquam varius, quam quis blandit aliquam, ipsum urna vulputate diam, vel gravida nibh velit mattis lacus. Aliquam aliquam scelerisque pellentesque.

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec aliquam arcu fringilla molestie iaculis. Ut vehicula nunc ex, ut rutrum dui tincidunt eget. Praesent eu volutpat dui. Morbi ante justo, ullamcorper et porttitor quis, aliquet sit amet libero. Sed id orci ultricies arcu viverra euismod. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum quis risus a urna aliquet molestie. Nam cursus laoreet neque sit amet sagittis. Donec non nulla in eros pellentesque scelerisque quis ac mi. Proin dignissim auctor orci, vitae pharetra enim scelerisque ac. In volutpat non nunc quis elementum. Aliquam varius, quam quis blandit aliquam, ipsum urna vulputate diam, vel gravida nibh velit mattis lacus. Aliquam aliquam scelerisque pellentesque.

Kevin Mandeville

Hacking emails with CSS

Speaker: Kevin Mandeville

Tired of designing emails that look to have been built 15 years ago?

Email development has evolved a lot, and now it is possible to enjoy things like:

  • Responsive design
  • Dynamic content
  • Fully interactive experiences

Fluid-to-fixed layout


              
...

Outlook does not support the box model


              
...

The Fab Four: grid system without media queries

It uses the width, min-width and max-width properties.

When used together, this is how they behave:

If...Actual width
width > max-widthmax-width
min-width > widthmin-width
min-width > max-widthmin-width

4-columns layout in desktop / 1-column layout in mobile


              .column {
  display: inline-block;
  min-width: 25%;
  max-width: 100%;
  width: calc((480px — 100%) * 480);
}
            
min-widthColumn width for desktop
max-widthColumn width for mobile
widthThis calculation creates a value bigger than max-width or smaller than min-width, so that either one of them is applied instead. The 480 value matches the desired breakpoint.

Dynamic content

Thanks to the content property, we can write the content of an element in a CSS rule.


              

              .dynamic::before {
  content: "Content written in CSS";
}
            

We can render empty elements in our emails and then include an external CSS file that will be generated on-demand. This file will have specified the content properties.

This will work only in clients based of WebKit, so we have to include a fallback using a dynamic image for non-WebKit clients.

Interactive emails

The checkbox hack allows us to include interactivity using the :checked pseudo-selector.


              
            

.interactive {
  background-color: blue;
}

input {
  display: none;
}

input:checked + .interactive {
  background-color: red;
}
            

With this hack, we can build more complex experiences like an image gallery.

Chris Lilley

WebFonts

Speaker: Chris Lilley

We can do much more than use custom fonts in our web applications

It is possible to modify how the numbers are displayed using font variants


              

1234567890ABC
1234567890abj


              .example {
  font-variant-numeric: oldstyle-nums;
}
            

1234567890ABC
1234567890abj


              
112,113.56
89,546.87
286,111.10

              .example {
  font-variant-numeric: tabular-nums;
}
            
112,113.56
89,546.87
286,111.10

              

1/2 3/4 13/27 86/483


              .example {
  font-variant-numeric: diagonal-fractions;
}
            

1/2 3/4 13/27 86/483

Other talks

SpeakerTalkSummary
Håkon Wium LieHåkon Wium LieWrite a bookHTML/CSS was not intended to be used just in a screen, we can write a book using them!
Philip WaltonPhilip WaltonThe Dark Side of Polyfilling CSSWriting polyfills for CSS is much harder than it might seem.
Val HeadVal HeadEasing functionsApply animations using easing equations help to have natural feeling when interacting with web applications.
Varya StepanovaVarya StepanovaPattern libraries through trial and errorHow to make changes to our styleguide being sure that we are not breaking anything

Thank you