ad CSS selectors from right to left it felt kinda weird and confusing. Boris Zbarsky explains why it's done that way in a way that makes perfect sense. Part of the reason:

...most of the selectors it's considering don't match the element in question. So the problem becomes one of deciding that a selector doesn't match as fast as possible; if that requires a bit of extra work in the cases that do match you still win due to all the work you save in the cases that don't match.

Direct Link to ArticlePermalink

Why Browsers Read Selectors Right to Left is a post from CSS-Tricks

]]> http://css-tricks.com/14093-why-browsers-read-selectors-right-to-left/feed/ 0 //AN_Xml: g to draw the user's attention to it. Jonathan Snook ported that idea to CSS and combined it with :target.

//AN_Xml:

Instead of yellow fade, we'll indicate which section the link we just clicked was referring to by nudging it over to the right and flashing a red border. Instead of making you think, here you go:

//AN_Xml:

//AN_Xml:

The structure is a bit of navigation that links to sections by ID:

//AN_Xml:
<nav>
//AN_Xml:  <a href="#one">1</a>
//AN_Xml:  <a href="#two">2</a>
//AN_Xml:  <a href="#three">3</a>
//AN_Xml:</nav>
//AN_Xml:
//AN_Xml:<section>
//AN_Xml:  <div id="one"><h2>One</h2>Pellentesque habitant morbi ...</div>
//AN_Xml:  <div id="two"><h2>Two</h2>Pellentesque habitant morbi ...</div>
//AN_Xml:  <div id="three"><h2>Three</h2>Pellentesque habitant morbi ...</div>
//AN_Xml:</section>​
//AN_Xml:

When the sections become in :target, the scoot over to the right a bit via translateX transform (prevents any weird text wrapping or anything we might get with padding) and a red border flashes on via keyframe animation.

//AN_Xml:
:target {
//AN_Xml:  -webkit-animation: highlight 1s ease;
//AN_Xml:  -moz-animation: highlight 1s ease;
//AN_Xml:  -webkit-transform: translateX(20px);
//AN_Xml:  -moz-transform: translateX(20px);
//AN_Xml:  -ms-transform: translateX(20px);
//AN_Xml:  -o-transform: translateX(20px);
//AN_Xml:}
//AN_Xml:@-webkit-keyframes highlight {
//AN_Xml:  0% { border-left-color: red; }
//AN_Xml:  100% { border-left-color: white; }
//AN_Xml:}
//AN_Xml:@-moz-keyframes highlight {
//AN_Xml:  0% { border-left-color: red; }
//AN_Xml:  100% { border-left-color: white; }
//AN_Xml:}
//AN_Xml:section > div {
//AN_Xml:  border-left: 40px solid white;
//AN_Xml:  padding: 10px;
//AN_Xml:  -webkit-transition: all 0.5s ease;
//AN_Xml:  -moz-transition: all 0.5s ease;
//AN_Xml:  -ms-transition: all 0.5s ease;
//AN_Xml:  -o-transition: all 0.5s ease;
//AN_Xml:  padding-right: 50px;
//AN_Xml:  margin-left: -20px;
//AN_Xml:}
//AN_Xml:

That's all there is too it really. I'd chalk this up under progressive enhancement, if you're worried about browser support. As in, it's just a nice touch, not vital.

//AN_Xml:

View Demo

//AN_Xml:

Fighting the Jump!

//AN_Xml:

Let's say you like the idea of using :target for states but dislike the page jumping behavior, you can change the hash link in a URL without a page jump.

//AN_Xml:

Using jQuery, you could target all hash-links, prevent their default behavior, and use pushState (or replaceState, I suppose) to change the URL (which won't move the page).

//AN_Xml:
$("a[href^=#]").on("click", function(e) {
//AN_Xml:  e.preventDefault();
//AN_Xml:  history.pushState({}, "", this.href);
//AN_Xml:});
//AN_Xml:

You could interchangeably use replaceState there too, which would change the URL without adding an entry to the browser history. Sometimes you might want that, sometimes you might not. At least you have a choice here, which you don't with the default behavior of clicking a hash link, which always adds.

//AN_Xml:

But there is bad news

//AN_Xml:

When the URL changes to a new hash, you'd think the current target would change and new CSS would take effect. It doesn't (tested current WebKit and Firefox at time of this writing). It's a bug.

//AN_Xml:

Theoretically, you could measure and save the current scroll position of the page, let the link move it naturally, then set it back to where it was. But that just sounds so awful I couldn't even bring myself to make a test page for it.

//AN_Xml:

More

//AN_Xml: //AN_Xml:

On :target is a post from CSS-Tricks

]]> //AN_Xml: http://css-tricks.com/on-target/feed/ //AN_Xml: 32 //AN_Xml: //AN_Xml: //AN_Xml: ShopTalk Episode 13 //AN_Xml: http://shoptalkshow.com/episodes/013-rapidfire-2/ //AN_Xml: http://css-tricks.com/shoptalk-episode-13/#comments //AN_Xml: Sun, 08 Apr 2012 18:15:07 +0000 //AN_Xml: Chris Coyier //AN_Xml: //AN_Xml: //AN_Xml: http://css-tricks.com/?p=16756 //AN_Xml:

Rapidfire show! No guest, no news, not hot drama, just all question on answer action.

//AN_Xml:

Direct Link to ArticlePermalink

ShopTalk Episode 13 is a post from CSS-Tricks

]]>
//AN_Xml: Rapidfire show! No guest, no news, not hot drama, just all question on answer action.

//AN_Xml:

Direct Link to ArticlePermalink

ShopTalk Episode 13 is a post from CSS-Tricks

]]>
//AN_Xml: http://css-tricks.com/shoptalk-episode-13/feed/ //AN_Xml: 0 //AN_Xml:
//AN_Xml: //AN_Xml: //AN_Xml: var xsltProcessor = new XSLTProcessor(); xsltProcessor.importStylesheet(xsl); var result = xsltProcessor.transformToDocument(xmlDom); var xmls = new XMLSerializer(); var data = (xmls.serializeToString(result)); data = data.replace(/ o Article — Permalink

CSS Shaders is a post from CSS-Tricks

]]> http://css-tricks.com/14584-css-shaders/feed/ 0 Darthttp://www.dartlang.org/ http://css-tricks.com/14580-dart/#comments Fri, 14 Oct 2011 16:02:03 +0000 Chris Coyier http://css-tricks.com/?p=14580

It's a new language the runs in the browser and servers. A lot of it is over my head, but I always celebrate new thinking especially when it has a bunch of smart people behind it. The obvious point is that, if it's a direct competitor to JavaScript, that JavaScript has far more browser support. I'm sure that fact isn't lost on the team.

Wasn't this the last Google-originated language? Did that go anywhere?

Direct Link to ArticlePermalink

Dart is a post from CSS-Tricks

]]>
It's a new language the runs in the browser and servers. A lot of it is over my head, but I always celebrate new thinking especially when it has a bunch of smart people behind it. The obvious point is that, if it's a direct competitor to JavaScript, that JavaScript has far more browser support. I'm sure that fact isn't lost on the team.

Wasn't this the last Google-originated language? Did that go anywhere?

Direct Link to ArticlePermalink

Dart is a post from CSS-Tricks

]]>
http://css-tricks.com/14580-dart/feed/ 0
New Poll: Ideal Page Weighthttp://css-tricks.com/14539-new-poll-ideal-page-weight/ http://css-tricks.com/14539-new-poll-ideal-page-weight/#comments Thu, 13 Oct 2011 17:01:46 +0000 Chris Coyier http://css-tricks.com/?p=14539 What do you think is reasonable page size to try and stay under for a modern web design?

New Poll: Ideal Page Weight is a post from CSS-Tricks

]]>
Since that last post was kind of a bust (in a good way!) - let's kick off another one right away. We'll keep it along the same lines: page weight, this time regarding the page as a whole.

Way back in the day Google used to only index 100k of a page (although I think that's the HTML only) but that's not true anymore. 200k for the entire page (including all resources: css, images, js, etc) used to be a common goal. I'd say very few web pages these day come in at under 200k.

The CSS-Tricks homepage right now weighing in at 607k

So the new poll is:

What do you think is reasonable page size to try and stay under for a modern web design?

Poll is in the sidebar.

New Poll: Ideal Page Weight is a post from CSS-Tricks

]]>
http://css-tricks.com/14539-new-poll-ideal-page-weight/feed/ 61
//AN_Xml: if(x[i].namespaceURI == "http://www.w3.org/1999/XSL/Transform" && (x[i].baseName == "import" || x[i].baseName == "include")){ var attr = attrs.getNamedItem("href"); if(attr != null){ x.item(i).setAttribute("href", _AN_full_url(attr.nodeValue)); } } } // Transform var content = myxml.transformNode(xsl); _AN_Call_write('write', document, content); } catch(e){ alert(e.description); } } } _AN_Display_xml();