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.
Gradient maps, they’re not just for desktop anymore…
gradientmaps.js is a library I wrote that leverages SVG Filters to enable you to easily apply a Gradient Map to any DOM element.
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.
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:
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:
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
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:
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!).
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.
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. caniuse.com 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.
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
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
Say you have a black & white image and want to display it in many different 2-color schemes.
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
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
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
I recently went over to the cnet.com 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
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
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
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
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
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