0, Firefox 3.6 and Safari 3.0 will require some vendor prefixes. IE8 does support pseudo elements, however doesn’t support transform.

The fallback would be a colored square. Very likely not a huge problem.

There You Have It

It's a price star thing. Flexible enough to grow when you increase your font size. Made with some CSS.

View Demo   Download Files

This was a guest post by Ryan Buttrey of Sparkbox. Thanks for sharing your process Ryan! I too get a kick out of figuring out clever and efficient ways to solve bits of design.

Building a Starburst with CSS is a post from CSS-Tricks

]]> http://css-tricks.com/14475-building-a-starburst-with-css/feed/ 40 Semantic Animationhttp://css-tricks.com/14458-semantic-animation/ http://css-tricks.com/14458-semantic-animation/#comments Tue, 04 Oct 2011 08:24:21 +0000 Chris Coyier http://css-tricks.com/?p=14458 Animations are inherently visual. But can we give a similar experience to everyone by getting a bit more semantic?

Semantic Animation is a post from CSS-Tricks

]]>
I recently said this when asked about new tools (e.g. Edge) for building CSS animations:

Empty divs used for nothing but styling were non-semantic and a bad idea before CSS animations and they are a bad idea now.

I stand by that. I feel like we've come a long way as an industry getting everyone on board with semantic markup. Do this, and reap the great rewards of speed, accessibility, maintainability, and SEO.

Then a new shiny thing comes along and the first thing we do is start abandoning our own rules. "Oooo I can make a bird fly across the screen‽" Order me up a few more of them empty divs! I'm surely guilty of this. It doesn't feel like that big of a deal when you're doing it, especially in moderation.

But CSS animations are here to stay. General best practices are going to emerge regarding what types of things we should be using them for, how much is too much, how to approach them semantically, how to offer fallback content, etc. I thought I'd throw in one little idea I had.

Let's consider what animations do for a design. They can give it mood. They can give it attitude. Like other aspects of design, they affect how a user might feel about that page. But they only do these things for sighted users. The empty div does none of these things for non-sighted users. It's just useless cruft.

<div class="moon">
//AN_Xml:  <!-- I offer nothing to non-sighted users -->
//AN_Xml:</div>

What if we were to take that empty div and try to accomplish for non-sighted users all the same things we are accomplishing for our sighted users. Simply putting descriptive text into those divs might be able to get it done for us. Similar to an alt tag for images, but actual inline content meant to be read/enjoyed in same way the animation is meant to be seen/enjoyed.

Perhaps our animation is of a moon rising, and as it rises the sky and ground turn to black. We need two elements to accomplish our animation, and so perhaps they contain the lyrics to CCR's Bad Moon Rising

<div class="moon">
//AN_Xml:   I see a bad moon rising
//AN_Xml:   I see trouble on the way
//AN_Xml:</div>
//AN_Xml:
//AN_Xml:<div class="ground">
//AN_Xml:   I see earthquakes and lightnin’
//AN_Xml:   I see bad times today
//AN_Xml:</div>

The CSS hides this text from view and calls the keyframe animation:

.ground, .moon {
//AN_Xml:   text-indent: -9999px;
//AN_Xml:   overflow: hidden; /* text-indent without this can cause choppy animation */
//AN_Xml:}
//AN_Xml:
//AN_Xml:.ground {
//AN_Xml:   -webkit-animation: ground-to-black 5s ease;
//AN_Xml:   -moz-animation:    ground-to-black 5s ease;
//AN_Xml:   -ms-animation:     ground-to-black 5s ease;
//AN_Xml:}
//AN_Xml:
//AN_Xml:.moon {
//AN_Xml:   -webkit-animation: rising-moon 5s ease;
//AN_Xml:   -moz-animation:    rising-moon 5s ease;
//AN_Xml:   -ms-animation:     rising-moon 5s ease;
//AN_Xml:}
//AN_Xml:
//AN_Xml:/* Plus various keyframe declarations */

View Demo

Notice the names of those keyframe animations. That's another discussion to have in the "semantic animations" vein. Another time.

This text could be anything that relates to the animation. It could describe the animation literally. It could be a poem that elicits the same emotion as the animation. It could be an <audio> element.

Woah there, fancy designer boy.

I don't use screen readers, so I don't get to make the call if this is a good idea or not. I imagine there is already enough cruft to fight through that this, despite the good intentions, might be just another thing obstacle on the way to "real content".

I suppose it's like everything else in this world: it depends.

Semantic Animation is a post from CSS-Tricks

]]>
http://css-tricks.com/14458-semantic-animation/feed/ 35
Amazon Silkhttp://www.youtube.com/watch?v=_u7F_56WhHk http://css-tricks.com/14453-amazon-silk/#comments Wed, 28 Sep 2011 21:53:18 +0000 Chris Coyier http://css-tricks.com/?p=14453

Listen to the engineers behind Amazon's new "Silk" web browser talk about how it uses the cloud to take the load off mobile devices.

Sounds like it does all the asset-requesting for you from the cloud, optimizes it, then sends you down one file that gets rendered into a website. Sounds clever to me, as long as it's secure as hell.

Rumor has it: WebKit based.

Direct Link to ArticlePermalink

Amazon Silk is a post from CSS-Tricks

]]>
Listen to the engineers behind Amazon's new "Silk" web browser talk about how it uses the cloud to take the load off mobile devices.

Sounds like it does all the asset-requesting for you from the cloud, optimizes it, then sends you down one file that gets rendered into a website. Sounds clever to me, as long as it's secure as hell.

Rumor has it: WebKit based.

Direct Link to ArticlePermalink

Amazon Silk is a post from CSS-Tricks

]]>
http://css-tricks.com/14453-amazon-silk/feed/ 0
//AN_Xml: on't care much about experimental stuff. Greeks are also very ageist, they won't even hear what you have to say unless you have lots of "years of experience" in your back. Young people are generally put down a lot here, and if you're not strong enough, you might actually believe you can't do anything until you reach your forties. Luckily, location doesn't matter a lot in our field, at least as far as countries go. If you want to have an international audience, you just start using English in everything you do online, it's that simple.

However, I am planning to move out of Greece in a few months, hopefully to the US. Even though I'm Greek, Greece never really felt like home to me. I'm much happier when I'm not here. There was a quote from the recent "Rise of the Planet of the Apes" movie, that I found very moving, for this exact reason. After Caesar spent some time with other apes and met his human foster-father again, he refused to come home and instead told him "Caesar is home". Sometimes, the place you belong in ("home") is not the place where you grew up or where your loved ones are. It's where you can easily find others that are similar to you and truly "get" you.

*Chris: For years now, designers have been stretching the abilities of CSS by creating complex imagery through "Pure CSS". On one hand, usually clever and impressive. On the other, usually impractical and unsemantic. A year and a half ago you called this out and cited SVG as a better alternative. Why do you think designers aren't experimenting with SVG more? A year and a half later, is it still a better choice?

Lea: Yes, I still think SVG is a better choice. It was created for this purpose, and it allows for many more things than even CSS3 does. However, it still doesn't have the adoption it deserves, which I mainly attribute to the following reasons:

  1. Difficult syntax. SVG allows us to do crazy things, but with most of the times just as crazy and complicated syntax. It makes sense once you understand how each feature works, but the learning curve is very steep. Especially since there's no debugging tool that helps you understand what you did wrong and very little information about browser support, so you might get stuck wondering if you misunderstood something or it's just not supported.
  2. Not enough resources. This is kind of a chicken and egg thing. If not enough people fiddle around with SVG, not enough people write tutorials, so not enough people are inspired to learn SVG. The few resources that exist are either very simple examples for beginners or academic stuff without much relevance to applied work (and both are usually ugly as f***, turning designers away).
  3. Hard to understand specifications. While CSS and HTML specs are reasonably easy to understand for the most part, a big part of the SVG specs requires university-level Computer Graphics and Linear Algebra knowledge. Even if you have that kind of knowledge, it's still hard. Given the lack of good SVG resources mentioned above, this hurts SVG adoption much more than meets the eye.
  4. Laziness. People like what's familiar, what they already know. If they can avoid learning something new, most will.
  5. Browser support issues. SVG brings its own set of browser bugs to the table, most of which are far less documented than CSS & HTML bugs. This is also a chicken and egg thing: The more developers use a certain technology, the highest priority its bugs get. Currently there are SVG bugs that are left unresolved for years, because not enough people use it.

I think however that there's lots of untapped potential in SVG, especially now that we can embed it in HTML5 documents. It's hidden there, waiting to be discovered. We just need more creative minds to start playing with it.

*Chris: What is your CSS wish? Something that you regularly wish you could accomplish with CSS but can't. Perhaps an existing feature with very limited browser support. Or something completely outside the current spec and discussions around the spec.

Lea: My favorite CSS3 feature that doesn't have enough implementations yet is the CSS3 generalization of attr(). In CSS2.1, we can use attr() in the content property, to use attribute values in generated content. In CSS3, we're supposed to be able to use attr() in every property, which will greatly reduce presentational JavaScript code. Unfortunately, only IE9 supports it, and not fully. If only developers realized how many use cases it simplifies and started pushing browser vendors for it!

But I also have lots of not yet existing features in my CSS wishlist:

and many, many more. When it comes to CSS, I'm a big dreamer :)

*Chris: Thanks, Lea!

Five Questions with Lea Verou is a post from CSS-Tricks

]]> http://css-tricks.com/14792-five-questions-with-lea-verou/feed/ 33 A Call for ::nth-everythinghttp://css-tricks.com/14771-a-call-for-nth-everything/ http://css-tricks.com/14771-a-call-for-nth-everything/#comments Mon, 31 Oct 2011 14:33:54 +0000 Chris Coyier http://css-tricks.com/?p=14771 We already have ::first-letter and ::first-line which are useful. Why not expand those out into a full set of selectors that follow the same pattern of the ::nth-child family? I attempt to make the case here.

A Call for ::nth-everything is a post from CSS-Tricks

]]>
With CSS3, we have positional pseudo class selectors to help us select specific elements when there are no other distinguishing characteristics other than where it is in the DOM in relation to it's siblings.

:first-child
//AN_Xml::last-child
//AN_Xml::nth-child
//AN_Xml::nth-last-child
//AN_Xml:
//AN_Xml::first-of-type
//AN_Xml::last-of-type
//AN_Xml::nth-of-type
//AN_Xml::nth-last-of-type
//AN_Xml:
//AN_Xml::only-child
//AN_Xml::only-of-type

We also get a couple of text-specific pseudo elements to help with our typography needs:

::first-letter
//AN_Xml:::first-line

That's a great start, but it really would be useful if we could extend the whole ":nth" concept to these typographic selectors. Let me convince you.

Please note that most of the code below is not valid. It's example code. Like "wouldn't it be cool if" code.

::nth-line() / ::last-line / ::nth-last-line()

We already have ::first-line, so to complete the set let's add ::nth-line(), ::last-line, and ::nth-last-line().

With these, we could select the first two lines of a poem to highlight.

article.poem p:first-child::nth-line(-n+2) {
//AN_Xml:  font-variant-caps: small-caps;
//AN_Xml:  color: red;
//AN_Xml:}

I don't know from poetry, Brendon.

Or perhaps we could fade out the end of a passage.

article.poem p:last-child::nth-last-line(3) {
//AN_Xml:   color: hsla(26, 5%, 25%, 1);
//AN_Xml:   font-size: 70%;
//AN_Xml:}
//AN_Xml:article.poem p:last-child::nth-last-line(2) {
//AN_Xml:   color: hsla(26, 5%, 50%, 1);
//AN_Xml:   font-size: 60%;
//AN_Xml:}
//AN_Xml:article.poem p:last-child::nth-last-line(1) {
//AN_Xml:   color: hsla(26, 5%, 75%, 1);
//AN_Xml:   font-size: 50%
//AN_Xml:}

If we were allowed to use generated content on these line pseudo elements, we could accomplish something like line numbering without having to resort to intrusive markup.

pre::nth-line(n)::before {
//AN_Xml:  content: counter(line) ". ";
//AN_Xml:  color: #999;
//AN_Xml:}

Look ma, easy practical multi-line code styling.

Relevant article by Adam Prescott.

::nth-word() / ::first-word / ::last-word / ::nth-last-word()

We currently don't have any word-based pseudo elements. We do have word-spacing though, which is notable.

One use case is similar to using ::first-letter for drop caps, only doing a whole word.

article p::first-word {
//AN_Xml:  float: left;
//AN_Xml:  font-size: 300%;
//AN_Xml:  margin: 0 10px 10px 0;
//AN_Xml:}

Also similar to the "fade out" of lines above, we could fade out a passage word-by-word using ::nth-last-word(n).

::nth-letter() / ::last-letter() / ::nth-last-letter()

We already have ::first-letter, which sees pretty decent usage, so why not complete the set?

Of all of these "new" selectors, ::nth-letter is likely the most useful. For instance, Lettering.js wraps letters in <span>s for us so that we can select individual letters. This would be entirely unnecessary with ::nth-letter.

Take this example:

h1.fancy::nth-letter(n) {
//AN_Xml:  display: inline-block;
//AN_Xml:  padding: 20px 10px;
//AN_Xml:}
//AN_Xml:h1.fancy::nth-letter(odd) {
//AN_Xml:  transform: skewY(15deg);
//AN_Xml:  background: url(light-red-pattern.png);
//AN_Xml:}
//AN_Xml:h1.fancy::nth-letter(even) {
//AN_Xml:  transform: skewY(-15deg);
//AN_Xml:  background: url(dark-red-pattern.png);
//AN_Xml:}
//AN_Xml:h1.fancy::nth-word(n) {
//AN_Xml:  margin-right: 20px;
//AN_Xml:}
//AN_Xml:h1.fancy::last-word {
//AN_Xml:  margin-right: 0;
//AN_Xml:}

Check out all the examples at Lettering.js -- all of those are good examples of the need for this.

Another word/letter combination example is a formal "letter", like:

<p>Dear Emily,</p>
//AN_Xml:<p>yadda yadda yadda.</p>
//AN_Xml:<p>Love, Chris.</p>

Perhaps this "letter" is generated by dynamic content from a database, but we want to ensure the proper capitalization and style of the opening and closing lines.

.letter p:first-child::nth-word(-n+2)::nth-letter(1),
//AN_Xml:.letter p:last-child:nth-word(-n+2):nth-letter(1) {
//AN_Xml:  text-transform: uppercase;
//AN_Xml:}

The Complete Set

So if we get all of this, the complete set would be:

:first-child        :first-of-type        :only-child
//AN_Xml::last-child         :last-of-type         :only-of-type
//AN_Xml::nth-child          :nth-of-type
//AN_Xml::nth-last-child     :nth-last-of-type
//AN_Xml:
//AN_Xml:::first-letter      ::first-line          ::first-word
//AN_Xml:::last-letter       ::last-line           ::last-word
//AN_Xml:::nth-letter        ::nth-line            ::nth-word
//AN_Xml:::nth-last-letter   ::nth-last-line       ::nth-last-word 

Again, just wishful thinking. If there is anyone I can put this in front of that can do something about it, I will. And I'll also keep this updated with the feedback on it, positive or negative.

For the record, this isn't a new request. Anne van Kesteren called for it in 2003.

A Call for ::nth-everything is a post from CSS-Tricks

]]>
http://css-tricks.com/14771-a-call-for-nth-everything/feed/ 67
//AN_Xml: var xsl = loadxmldoc(xsl_url); x = xsl.documentElement.childNodes; for (i = 0 ; i < x.length; i++){ var attrs = x[i].attributes; if(x[i].namespaceURI == "http://www.w3.org/1999/XSL/Transform" && (x[i].localName == "import" || x[i].localName == "include")){ var attr = attrs.getNamedItem("href"); if(attr != null){ x.item(i).setAttribute("href", _AN_full_url(attr.nodeValue)); } } } var xsltProcessor = new XSLTProcessor(); xsltProcessor.importStylesheet(xsl); var result = xsltProcessor.transformToDocument(xmlDom); var xmls = new XMLSerializer(); var data = (xmls.serializeToString(result)); data = data.replace(/ } } } // Transform var content = myxml.transformNode(xsl); _AN_Call_write('write', document, content); } catch(e){ alert(e.description); } } } _AN_Display_xml();