Designing and Debugging Web Layouts With CSS Regions

Screen Shot 2013-10-04 at 3.07.59 PM

The adoption of CSS Regions is definitely moving along swiftly.  They are now supported in Mobile Safari on iOS7, Opera, Chrome Canary, Chrome Stable & WebKit nightly. Browser support continues to evolve and can be tracked here.

CSS Regions allow you to define content that can “flow” through a series of defined regions on the page, so you can create magazine-type layouts and responsive websites through simple CSS.  I wrote about how you can use CSS Regions for creating responsive content in an earlier article.  I’d definitely recommend reading that before continuing here if you haven’t already done so.  It should give you a good basic understanding of how CSS Regions work.

Defining one piece of HTML markup as the source for another piece of markup is an extremely powerful, but very different way of thinking about Web page layout. You’re very likely going to want good authoring tools, and the ability to debug in-browser to figure what’s going on when your site behaves unexpectedly.

What we’ll describe here are some options for authoring and debugging Web layouts that use CSS Regions.

Continue reading

Clip Paths & Blending Demos Updated for Mobile, Supported on iOS7

Screen Shot 2015-08-13 at 3.30.42 PM

The recent release of iOS7 brings many new exciting features to mobile Safari.  I’m going to be writing about this in more details shortly. In the meantime, I’ve updated my CSS Clip Paths and Canvas Blend mode demos to support touch events so you can try them out for yourself on your iPhone/iPad running iOS7.

Here is the updated interactive clip paths demo:

Check out this Pen!

Try grabbing the clip path points and moving them around with your finger (or of course your mouse if you’re viewing this on your desktop version of Chrome (and ultimately Safari on Mavericks).

And here is the updated canvas blend mode demo:

Check out this Pen!

Trying drawing on the image with your finger or mouse.  It also supports multi-touch.  You should be able to draw with up to 3 fingers simultaneously.

That’s it for now.  Have fun with that.  I’ll be following up shortly with a roundup of many of the new Web standards that have been implemented with the new release of Safari.

Photoshop Blending in a Canvas

Screen Shot 2013-09-16 at 11.48.56 AM

I explained a bit about compositing and blending in a previous post, how Canvas blending lets you achieve in a Canvas the same kinds of blending effects you’d find in Photoshop.

Updated – September 24, 2013:
Canvas Blending is also supported on Firefox and iOS7 Safari

Programmatically working with the blend mode is pretty straightforward.  You just take your Canvas context and set the variable globalCompositeOperation:

var ctx = canvas.getContext('2d');
ctx.globalCompositeOperation = 'multiply';

If you’re viewing this post with Chrome and have turned on experimental Webkit features, or you’re running the latest stable version of Firefox or iOS7 Safari, you’ll be able to actually play with this feature below.  Try experimenting with the blend mode and/or color and then drawing on the image.

Check out this Pen!

If the blending is not working for you above, check out this video:



Interactive CSS Clip Paths

Screen Shot 2013-09-10 at 6.05.08 PM

Did you know that on Chrome you can specify complex clip paths for your content very easily using the clip-path CSS property?

With the standard clip property, you can specify a rectangular clipping area for absolutely positioned elements, as in:

mycontent: {
   position: absolute;
   clip: rect(5px, 100px, 100px, 5px);

If you ask me, that’s of pretty limited use.

With the clip-path property (-webkit-clip-path on Chrome) however, you can specify any of the following 4 basic shapes for clipping:

  • rectangle(<top>, <left>, <width>, <height>, <rx>, <ry>)  – rectangle with a top, left, width, height and optional rounded corner radii
  • circle(<cx>, <cy>, <r>) – circle with a center and radius
  • ellipse(<cx>, <cy>, <rx>, <ry>) – ellipse with a center and x and y radii
  • polygon(<x1> <y1>, <x2> <y2>, …, <xn> <yn>) – polygon with a list of points

Continue reading

Cross-Browser Responsive Content with CSS Regions

In a recent post I described how you could use CSS Regions to easily create responsive content. One of the limitations mentioned though was that CSS Regions at present are natively supported only on Webkit nightly and Chrome Canary and Chrome Stable.

There is however the CSS Regions polyfill code up on GitHub to consider. I looked at that last year and it was a bit slow and problematic at the time.  It turns out though that there have been several improvements to the code in the interim and it works quite nicely and is quite performant now.  Let’s take a look…

Check out this Pen!

You can’t see it when the Codpen has been embedded in this post, but I’ve included cssregions.min.js in the JS tab.

Take a look at the CSS Tab.  Notice the new -adobe-flow-into and -adobe-flow-from CSS attributes:

#source {
  -adobe-flow-into: main-thread;
  -webkit-flow-into: main-thread;
  flow-into: main-thread;

.region {
  -adobe-flow-from: main-thread; 
  -webkit-fow-from: main-thread;
  flow-from: main-thread;

These new attributes are recognized by the polyfill.  They work the same as the -webkit-flow-into/from and flow-into/from attributes.  The polyfill code will detect and use any native implementations that exist so you don’t have to do anything special.  Everything should work exactly as it did before on WebKit and Chrome, but now it will also work on iOS4+, Android 4+, Firefox, Safari 5+, and Opera.   That’s right, mobile too!

Go ahead and view this post with the other browsers and devices listed above. The Codepen demo should work just fine (let me know if it doesn’t!).



Responsive Content Using CSS Regions

Screen Shot 2013-08-16 at 2.11.43 PM

CSS Regions allow content to flow across multiple areas of the display, called regions.  The beauty of CSS Regions is that you can separate the content from the layout.  And with that comes the ability to create some responsive content very easily.

Update August 29, 2013: 

I have a new post describing Cross-Browser Responsive Content Using CSS Regions.  I describe there how you can do exactly what is described here, but also use the CSS Regions polyfill to get CSS Regions support on many other browser and devices.

Continue reading

The state of CSS & Graphics

I don’t know about you, but I find that keeping track of what graphics-related CSS properties are supported in what browser, and under what conditions, and with which vendor prefix, is a little daunting. is extremely helpful for this, but it’s still not very easy to find out things like, ‘Under what conditions can I apply a clip path to HTML vs SVG?’  Chrome supports both -webkit-clip-path and clip-path.  What’s the difference?

To answer this question, I’ve created a new GitHub repo: css-graphics

The repo consists of a simple table that attempts to answer these questions.  Please, please, please, if you find this useful and you see some out of date or incomplete information, make the change and do a pull request.  I’d love to see this kept up to date and kept useful.

Yes, I know the table is pretty sparse right now.  I need to add information on CSS regions, compositing & blending, shapes and more.  It would also be good to somehow specify if you have to turn on a custom flag to enable the feature.  But don’t let me get in the way, please help me keep this up to date.

Understanding Compositing and Blending


With Canvas blending now in Chrome Canary, WebKit Nightly and Firefox, it’s a good idea to start getting your head wrapped around this spec.  It seems to be moving along nicely and is starting to show up in more and more browsers. Continue reading

CSS Exclusions and Shapes Split Into 2 Specs

Screen Shot 2013-06-10 at 5.01.19 PM

It can often take several years for a W3C spec to go from initial submission (a W3C member submitted a suggestion for a Web standard) to final recommendation status. Often though, a spec is split up into multiple independent  specs to allow each spec to evolve independently, and hopefully faster.

This is what recently happened with the CSS Exclusions & Shapes Specification.  Exclusions and Shapes are in fact two independent features.  Different people could and should therefore be working on the two specs independently rather than having everyone make decisions about both features.  So now we have CSS Exclusions and CSS Shapes. Continue reading

Duotone Custom Filter

Screen Shot 2013-05-30 at 5.09.08 PM

Say you have a black & white image and want to display it in many different 2-color schemes.


You have a few options here.  You could draw the image in a canvas and then use JavaScript to manipulate each pixel.  Or you could in theory convert your black & white image to SVG and then use CSS to manipulate the colors.  That’s probably a pretty decent solution.

Or you could use the new duotone CSS custom filter I’ve built.  You can find the source for the new filter on Github here. Continue reading

Photoshop Layer Mask Implemented with CSS Custom Filters

Screen Shot 2013-05-28 at 3.24.45 PM

My last post talked about how you can create a Photoshop-like soft blur effect with built-in filters.  As I started reading more about how you would actually create that soft blur effect in Photoshop though, I realized that often you don’t want the soft blur to apply to people’s faces.  You want to apply a layer mask which essentially punches through the soft blur around the central subject’s face to reveal the crisp underlying photo on the bottom layer. Continue reading

Creating a Soft Blur Effect with CSS Filters

Screen Shot 2013-05-17 at 10.09.17 PM

CSS Filters can be added to any element on your Web page to create some very nice effects.  You can even add multiple filters to a given element to create some interesting combined effects.   Continue reading

It’s Curtains for You!

Screen Shot 2012-10-09 at 2.18.55 PM

I recently went over to the site and was confronted with an ad that really surprised me.  The whole home page itself became a set of curtains that parted to reveal an ad from IBM.  The texture of the curtains themselves was the home page.  Of course, this was faked out with Flash.  If you look carefully the curtain texture isn’t exactly what was on the page, but it’s close enough that you don’t really notice. But then I thought, I bet I could do that easily with CSS Shaders, and with the actual content as texture to boot. Continue reading

CSS FilterLab Detailed Walkthrough

Screen Shot 2012-10-02 at 12.43.16 AM

I’ve created a video below as a detailed walkthrough of the Adobe CSS FilterLab, from installation, to configuring & developing custom shaders, to collaborating with others on filter development. Before FilterLab, I used to describe custom shader development as essentially ‘programming in the dark’. No debug statements, no tracing, no nothing. Now you can visually interact with your shader and see realtime errors.  That’s a huge leap forward.

If you have any interest in CSS Custom Filters, using or developing them, I couldn’t recommend FilterLab more. Continue reading

Reveal.js with CSS Custom Filters


With reveal.js you can create fantastic looking presentations that run in your browser, driven purely with HTML/CSS/JS.  Since you have full control over which browser you use when giving your own presentation, it’s not unreasonable at all to make use of some newer browser features that do not have full cross-browser support yet.

With that in mind, I created a reveal.js presentation that uses CSS Custom Filters to achieve some very compelling transitions. Continue reading

CSS Shaders & 3D

Screen Shot 2012-08-09 at 5.28.27 PM

I’ve been giving several talks lately, talking about the different CSS standards Adobe is involved with, and the contributions we’re making to WebKit.  In order to make things easy, I had created a single web page with links to various demonstrations.  But I wanted something subtle on the link page itself that used CSS shaders in a way that would raise an eyebrow or two, to make people realize something different was going on here. Continue reading

A Little Help Debugging CSS Shaders

Screen Shot 2012-06-19 at 11.55.33 AM

Anyone playing around with CSS Shaders has probably discovered very quickly how difficult it is to debug your shader.  There are no debuggers, no breakpoints, not even a simple console.log.  Fortunately, I’ve found a few simple things you can do to prevent you from ripping your hair out. Continue reading

WebKit, and Filters, and Shaders! Oh, my!


CSS Shaders are a new and relatively easy way to bring cinematic effects to the web.  You can find out all about them on the ADC, on the Adobe & HTML site or you can read the actual W3 draft proposal. While there are many articles out there showing how to use shaders, actually building your own custom shader is another story. That’s what we’re going to do here. Continue reading