background-size property overwritten by background shorthand by Firefox

As I start to use new CSS3 properties more often new issues are arising that I didn’t have to deal with before. Building out a new responsive site now that is using retina images for the mobile site so I’m using the background-size property extensively. I ran into a bug in Firefox 11 where in some situations the property was ignored.

Here’s an example of the code that did not work in Firefox:

112
113
114
115
116
117
118
119
120
121
122
123
124
125
.author:after {
	background-size: 30px 30px;
	content: "";
	height: 30px;
	padding: 0;
	position: absolute;
	right: -32px;
	top: 0;
	width: 30px;
}
 
.author-brian .author:after {
	background: url(/img/avatar-brian.png) right top no-repeat;
}

Turns out, using the background shorthand was overwriting the size. Adding the background-size property to the more specific author declaration fixed the issue.

It looks like this is actually correct behavior according to the spec. Using the shorthand overwrites all other background properties. From the Standarista site’s notes on CSS3 background properties:

If you use the background shorthand and fail to declare any of the individual properties that make up the shorthand, those properties will revert to their default values […].

I thought it was time to learn the more detailed background shorthand that includes the new properties like background-size and background-clip. However, the W3C’s spec for it isn’t actually supported by seemingly any browsers yet. Here’s what the new shorthand declaration of the code should be:

123
124
125
.author-brian .author:after {
	background: url(/img/avatar-brian.png) right top / 30px 30px no-repeat;
}

Unfortunately, that valid line of CSS breaks in every browser I tried it on and results in the image not displaying at all. I ended up needing to define the background-size property separately after the shorthand declaration:

123
124
125
126
.author-brian .author:after {
	background: url(/img/avatar-brian.png) right top no-repeat;
	background-size: 30px 30px;
}

The actual code will vary depending on what you’re doing but the important thing is to not forget to include the other background properties even if you’re not specifying them in your shorthand.

Our Favorite Web Design Trends of 2011

Last year was yet another huge one on the Web as things continued to move forward at a breakneck pace. The explosive growth of traffic from mobile devices influenced everything and meant huge advances in both technology and new ideas. Here are some of our favorite trends of 2011:

Responsive Design Goes Big Time

boston-globe-responsiveA responsive website uses fluid layouts, flexible images, and media queries to deliver an experience adapted for whatever width browser or device is being used. With the increasing number of mobile and desktop resolutions that must be accounted for, true responsive design solutions use CSS and media queries to flex to handle any width and adjusted layouts for popular breakpoints.

Coined by Ethan Marcotte back in 2010, responsive web design went all the way from unproven concept to misused buzzword in 2011. When the responsively redesigned BostonGlobe.com launched in September it signified loud and clear that responsive design wasn’t just for designer portfolio sites anymore. Responsive concepts can and should be considered for any new site developed in 2012.

Learn more: Responsive Web Design: What It Is and How To Use It, Responsive Web Design: The Book

@font-face Brings Beautiful Type to the Web

typekitWeb typography has been something designers have been forced to struggle with from the earliest days of the Web. As a developer, reminding the design team that they need to choose a web safe font and their options are still just “Arial or Verdana” always results in dropped heads. No more. The ability to embed nearly any font you want using @font-face puts all the power and creativity back into the designer’s hands. Add to it CSS3 properties such as text-shadow and tools such as Lettering.js and FitText, and suddenly the Web is a more beautiful place.

A technology that was around long before 2011, embedding web fonts using @font-face exploded last year and saw some major advances as more type foundries licensed their fonts for web embedding. With more quality fonts available (and many available for free), most projects that MarketNet works on now end up including embedded fonts for headings or navigation elements.

Also in 2011, Typekit, an innovator and leader in hosted web fonts, was acquired by Adobe. The acquisition signifies broad support for @font-face and should mean the inclusion of Typekit capabilities in future releases of Adobe’s Creative Suite tools.

Learn more: Modern Techniques for Web Typography, The Essential Guide to @font-face, @font-face face off

Constant (and Automatic) Browser Updates

firefox-updateInternet Explorer 6 was released over 10 years ago and it’s lack of capabilities and bugs could still end up restricting a web project in 2011. Crazy, right? Fortunately a similar issue shouldn’t be able to occur again. Web browsers are finally updating as quickly as web technology and ideas are, and more importantly they’re doing it automatically without needing users to be savvy enough to know that they need to update their computers.

Google Chrome has been pushing out autoupdates for a while now (and still does it the best), but in 2011 the teams behind both Firefox and Internet Explorer announced they would be doing the same. Now on an aggressive six-week release cycle, Firefox went from version 4.0 to version 9.01 between April and the end of the year. In December, joyous noises were heard from developers across the globe as Microsoft joined the party with the news that Internet Explorer all the way back to Windows XP would now autoupgrade to the latest available version.

Learn more: Mozilla’s Right: Bring on the Browser Updates, IE to Start Automatic Upgrades across Windows XP, Windows Vista, and Windows 7

What Will Be the Trends of 2012?

What new tech will be out in 2012? Will Google TV or the rumored new Apple TV set make an impact? How will Android Ice Cream Sandwich influence mobile design? Mobile will continue to grow and will influence many companies to target mobile first when launching new projects.

Mozilla Jetpack? Utilize JavaScript, HTML, and CSS to build Firefox extensions.

Mozilla Labs, the people behind the Firefox web browser, have recently announced their newest project: Jetpack. Jetpack is… well it’s a little complicated. From an end user’s point of view, Jetpack will be another type of extension you can install to add features for your browser. For developers, it’s an API to write add-ons for Firefox (and maybe “more” according to Mozilla) using technologies you already know. Continue reading “Mozilla Jetpack? Utilize JavaScript, HTML, and CSS to build Firefox extensions.”