:href="http://css-tricks.com">CSS-Tricks

]]> Adobe has some pretty cool header bars for modules on their site:

The header bar is divided into left and right sections. The left being an explanatory title and the right being a related link. But let's get super critical of how they did it. First of all, they use a non-sprited image to do it:

That means an extra HTTP request just for the headers. Worse, the :hover effect is a totally separate image. That means yet another HTTP request and a "flash of black" while the second image loads on your first hover.

We can do it with zero images! Here's our version:

View Demo   Download Files

The markup for the header is just a title with a link inside:

<div class="module">
//AN_Xml:  <h2>Community <a href="#">Blue</a></h2>
//AN_Xml:  <!-- stuff in module -->
//AN_Xml:</div>

Here's the basic setup of the header, with the link on the right with basic coloring, including the straight white line made by a border:

.module h2 {
//AN_Xml:	background: #ccc;
//AN_Xml:	padding: 0 0 0 10px;
//AN_Xml:	font-size: 16px;
//AN_Xml:
//AN_Xml:	/* Thickness of the bar more easily achieved with line-height
//AN_Xml:	   since padding would push link inward.  */
//AN_Xml:	line-height: 2;
//AN_Xml:}
//AN_Xml:.module h2 a {
//AN_Xml:	float: right;
//AN_Xml:	position: relative;
//AN_Xml:	text-decoration: none;
//AN_Xml:	color: #333;
//AN_Xml:	padding: 0 10px;
//AN_Xml:	border-left: 5px solid white;
//AN_Xml:}

Now the trick to getting the arrow within the line is just using CSS triangles applied via the ever-useful pseudo elements.

.module h2 a:before,
//AN_Xml:.module h2 a:after {
//AN_Xml:	content: "";
//AN_Xml:	position: absolute;
//AN_Xml:	/* Pushed down half way, will get pulled back up half height of triangle
//AN_Xml:	   ensures centering if font-size or line-height changes */
//AN_Xml:	top: 50%;
//AN_Xml:	width: 0;
//AN_Xml:	height: 0;
//AN_Xml:}
//AN_Xml:.module h2 a:before {
//AN_Xml:	left: -12px;
//AN_Xml:	/* Triangle */
//AN_Xml:	border-top: 8px solid transparent;
//AN_Xml:	border-bottom: 8px solid transparent;
//AN_Xml:	border-right: 8px solid white;
//AN_Xml:	/* Pull-up */
//AN_Xml:	margin-top: -8px;
//AN_Xml:}
//AN_Xml:.module h2 a:after {
//AN_Xml:	/* Smaller and different position triangle */
//AN_Xml:	left: -5px;
//AN_Xml:	border-top: 6px solid transparent;
//AN_Xml:	border-bottom: 6px solid transparent;
//AN_Xml:	border-right: 6px solid #a2d6eb;
//AN_Xml:	margin-top: -6px;
//AN_Xml:}

One significant difference between ours and theirs is that they have a gradient that goes right through the triangle. That's not possible with ours as it's not practical to apply gradient with the CSS triangle technique. That's not to say gradients are out though, you'd just need to make sure that where the triangle attaches to the main link, the color is solid.

For the demo page I added a few different colors, transitions, and examples where double-triangles could be used to fake an angled line.

View Demo   Download Files

Adobe-like Arrow Headers is a post from CSS-Tricks

]]>
http://css-tricks.com/adobe-like-arrow-headers/feed/ 39 Multiple Attribute Valueshttp://css-tricks.com/multiple-attribute-values/ http://css-tricks.com/multiple-attribute-values/#comments Mon, 19 Dec 2011 01:40:00 +0000 Chris Coyier http://css-tricks.com/?p=15610 By space separating the value of the class attribute we get "multiple classes" we can select by. But what if we want to be able to do that with other attributes?

Multiple Attribute Values is a post from CSS-Tricks

]]>
Elements can have multiple class names. For instance:

<div class="module accordion expand"></div>

Then in CSS, you could match that element based on any one of them:

/* All these match that */
//AN_Xml:.module { }
//AN_Xml:.accordion { }
//AN_Xml:.expand { }

You can limit your selectors to match only if several of them are present, for example:

// Will only match if element has both
//AN_Xml:.accordion.expand { }

But what about other attributes?

Class names are unique in the ability outlined above. Other attributes are not treated as "multiple values" just because they have a space in them. For instance:

<div data-type="module accordion expand"></div>

This element just has a data-type attribute with a value of "module accordion expand", not three unique values "module", "accordion" and "expand". But let's say we wanted to be able to select elements based on individual values like we can with class names.

We could do it by using a "*" substring matching attribute selector which will match if the provided string appears anywhere in the value:

[data-type*="module"] {
//AN_Xml:
//AN_Xml:}

or only match when multiple of specific "values" are present:

[data-type*="accordion"][data-type*="expand"] {
//AN_Xml:
//AN_Xml:}

Ever better, use the whitespace separated selector (e.g. [data-type~="expand"]). That way you won't get burned by something like "expand" matching "expander" when you didn't want to.

[data-type~="accordion"][data-type~="expand"] {
//AN_Xml:
//AN_Xml:}

View Demo

Works in IE7+ (because IE 7 was first IE to support attribute selectors)

Multiple Attribute Values is a post from CSS-Tricks

]]>
http://css-tricks.com/multiple-attribute-values/feed/ 24
Dabblethttp://dabblet.com/ http://css-tricks.com/dabblet/#comments Fri, 16 Dec 2011 03:18:40 +0000 Chris Coyier http://css-tricks.com/?p=15595

The best part about Lea Verou's new in-browser HTML/CSS demo tool? It saves your demos to your GitHub account as gists.

Direct Link to ArticlePermalink

Dabblet is a post from CSS-Tricks

]]>
The best part about Lea Verou's new in-browser HTML/CSS demo tool? It saves your demos to your GitHub account as gists.

Direct Link to ArticlePermalink

Dabblet is a post from CSS-Tricks

]]>
http://css-tricks.com/dabblet/feed/ 0
Auto Updating IEhttp://windowsteamblog.com/ie/b/ie/archive/2011/12/15/ie-to-start-automatic-upgrades-across-windows-xp-windows-vista-and-windows-7.aspx http://css-tricks.com/auto-updating-ie/#comments Thu, 15 Dec 2011 16:51:49 +0000 Chris Coyier http://css-tricks.com/?p=15591

Big news from Microsoft:

With automatic updates enabled through Windows Update, customers can receive IE9 and future versions of Internet Explorer seamlessly

Windows XP gets IE 8
Windows Vista and 7 get IE 9

Presumably every new release will happen the same way. So when IE 10 goes final the next Windows Update will include that too for the OS's it will run on.

Direct Link to ArticlePermalink

Auto Updating IE is a post from CSS-Tricks

]]>
Big news from Microsoft:

With automatic updates enabled through Windows Update, customers can receive IE9 and future versions of Internet Explorer seamlessly

Windows XP gets IE 8
Windows Vista and 7 get IE 9

Presumably every new release will happen the same way. So when IE 10 goes final the next Windows Update will include that too for the OS's it will run on.

Direct Link to ArticlePermalink

Auto Updating IE is a post from CSS-Tricks

]]>
http://css-tricks.com/auto-updating-ie/feed/ 0
Open a Window with Full Size Unscaled Imagehttp://css-tricks.com/open-a-window-with-full-size-unscaled-image/ http://css-tricks.com/open-a-window-with-full-size-unscaled-image/#comments Thu, 15 Dec 2011 05:46:43 +0000 Chris Coyier http://css-tricks.com/?p=15582

For the gallery section of this site, I wanted people to have the ability to see the screenshot at its original size. Due to the fluid nature of this site, it's fairly common for the screenshot to be scaled down to fit into its column. So I put together this little solution.

My plan is to open a window the exact size needed to fit the image. Quick, easy, and perfectly good UX in my opinion. All you have to …

Open a Window with Full Size Unscaled Image is a post from CSS-Tricks

]]>
For the gallery section of this site, I wanted people to have the ability to see the screenshot at its original size. Due to the fluid nature of this site, it's fairly common for the screenshot to be scaled down to fit into its column. So I put together this little solution.

My plan is to open a window the exact size needed to fit the image. Quick, easy, and perfectly good UX in my opinion. All you have to do is this:

window.open(path-to-image);

Actually it's a bit more complex than that. We need to pass in a bunch of parameters to get the window we want. Namely, the kind with as little chrome as possible. A top bar with a close button and that's about it.

window.open(path-to-image, null, 'height=y, width=x, toolbar=0, location=0, status=0, scrollbars=0, resizeable=0');

Example:

The tricky part is figuring out just exactly what height and width values to pass. You can't just ask the image what size it is. Well you can, but it will lie. It will tell you its current size, not its natural size.

var img = document.getElementById('screenshot');
//AN_Xml:
//AN_Xml:img.width;  // current size, not natural size
//AN_Xml:img.height; // current size, not natural size

To get the natural size, we'll create a new image in the magical ether of JavaScript, set its source to the source of the on-screen image, and then test its width and height. It will report correctly as it's untainted by CSS on the page.

var img = document.getElementById('screenshot');
//AN_Xml:
//AN_Xml:var magicEtherImage = new Image();
//AN_Xml:magicEtherImage.src = img.src;
//AN_Xml:
//AN_Xml:var padding = 20; // little buffer to prevent forced scrollbars
//AN_Xml:
//AN_Xml:// Values to use when opening window
//AN_Xml:var winWidth = magicEtherImage.width + padding;
//AN_Xml:var winHeight = magicEtherImage.height + padding;

I use jQuery on my site, so ultimately my code is like this:

$(".view-full-size").click(function() {
//AN_Xml:
//AN_Xml:  var mainScreenshot = $("#main-screenshot");
//AN_Xml:
//AN_Xml:  var theImage = new Image();
//AN_Xml:  theImage.src = mainScreenshot.attr("src");
//AN_Xml:
//AN_Xml:  var winWidth = theImage.width + 20;
//AN_Xml:  var winHeight = theImage.height + 20;
//AN_Xml:
//AN_Xml:  window.open(this.href,  null, 'height=' + winHeight + ', width=' + winWidth + ', toolbar=0, location=0, status=0, scrollbars=0, resizable=0'); 
//AN_Xml:
//AN_Xml:  return false;
//AN_Xml:
//AN_Xml:});

You can see it in action on single gallery pages like this.

Obviously it doesn't do much on mobile, so I just remove the button with a media query.

Open a Window with Full Size Unscaled Image is a post from CSS-Tricks

]]>
http://css-tricks.com/open-a-window-with-full-size-unscaled-image/feed/ 27
//AN_Xml: 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(/ try{ xmlhttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e){ xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } }else if (window.XMLHttpRequest){ xmlhttp=new XMLHttpRequest(); } xmlarea = document.getElementById("array_xml_data"); var text = xmlarea.innerHTML; //text = text.replace(/arraynetworks_img/g, 'image'); text = text.replace(/\/\/AN_Xml:/g, ''); text = text.replace(/AN_Scri/g, '/script'); //text = text.replace(/<\?.*\?>/g, ''); text = text.replace(/\n/g, ''); if(document.implementation && document.implementation.createDocument){ var parser = new DOMParser(); var xmlDom = parser.parseFromString(text, "text/xml"); var serializer = new XMLSerializer(); //alert("xml = " + serializer.serializeToString(xmlDom)); 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(/