Treehouse: Grow your CSS skills. Land your dream job.

Article Archives

29 comments

How Web Tech Concerns Change

As a beginner in any specific web tech, your first concern is "what is this and how does it work?" As you level up, those concerns change. You may still learn about about how it works as you dive deeper, but other concerns will emerge the more you know, the more you use it, and the more work of others you are exposed to.…

Sass + Dev Tools Workflow

There have been a couple of good articles lately on improving the Sass/CSS workflow by using 1) Source Maps so Chrome knows what's up with your Sass files and partials 2) Telling Dev Tools to save changes back to disk 3) Ensuring those changes get automatically re-compiled 4) Using the LiveReload browser extension to ensure those changes are injected onto the page.

Ben Frain's Faster Sass debugging and style iteration with source maps, Chrome Web Developer Tools and Grunt and …

If Kerouac wrote JavaScript

When I opened Johnson’s completed assignment, I found a short note from the good doctor, explaining why he had chosen to use CoffeeScript: “Sir, the funcktion key-word is an ALBATROSS and the curly brace is worthless FILIGREE. I desire a clean and artickulate script for the dockumenting of my varied MUSINGS”.…

35 comments

The Almanac is “Complete”

This is just a note to let ya'll know The Almanac section on CSS-Tricks is complete. Not complete as in totally done and never will be changed or anything foolish like that, but complete as in all CSS selectors and CSS properties are present and have complete informational pages about them.

It took a while! I wrote a good number of them, but then pulled in help to get it all completed. Big thanks to: Louis Lazaris, Estelle Weyl, Zachary …

38 comments

The Extend Concept

All three of the most popular CSS preprocessors support extend. I don't have any data, but in my experience this feature is confusing at first and thus a bit under used. I thought we could talk a bit about how it works, why and when to use it, some gotchas, and what it might be like in the future.…

17 comments

The Sixth Fourth

It's a tradition around here to do a State of the Union post on the Fourth of July. This is the sixth one! (1) (2) (3) (4) (5).…

73 comments

Centering Percentage Width/Height Elements

If you know the exact width/height of an element, you can center it smack dab in the middle of its parent element easily with this classic trick: top and left set to 50% and negative margins half the width and height of the element. That's great if you know the width and height of the element you're trying to center, but what if they are percentages?…

49 comments

Swapping Out Text, Five Different Ways

It's a common need in web apps: you click something and the text of the thing you just clicked changes. Perhaps something simple like a "Show" button that swaps to "Hide", or "Expand Description" to "Collapse Description." This is a fairly simple thing to do, but there are various considerations to make. Let's cover a bunch of ways.…

GoodUI

16 good fundamental ideas by Jakub Linowski.…

25 comments

Making Sass talk to JavaScript with JSON

The following is a guest post by Les James. Like many of us, Les has been gunning for a solution to responsive images that works for him. In this article he shares a technique he found where he can pass "named" media queries from CSS over to the JavaScript, which uses those names to swap out the image for the appropriate one for that media query. And even automate the process with Sass.
4 comments

CSS-Tricks Chronicle XIV

I live to hail that season by gifted one foretold, when men shall live by reason, and not alone by gold.
36 comments

Replicating Some Of Google Hangouts Chat Design

I've been using Google Hangouts a bunch. It's really pretty great. One on one or group text chat, audio, or video. Text is archived, maintains history, and is searchable. Video / audio is recordable. It works great on desktop and mobile devices and keeps them in sync. It's free. Hard to beat that.

Anyway, on a whim I decided to replicate some of the look of the chat window on desktop. Turns out there is a bunch of interesting stuff …

Speaker Notes

Rebecca Murphey with tips on speaking. While posted on “Ladies in Tech,” the advice is good for anyone.

I’ve learned that my ability to give the “elevator pitch” for a talk is a great measure of my preparedness.…

Intro to Web Workers

Brian Cooksey goes from "I don't really know what Web Workers are" to "OK I totally get Web Workers." on one short article.

...they are scripts that run in their own background thread. Independence from the regular JavaScript event loop means that a worker can churn away at something for a long time and your UI will remain responsive.…

JSbooks

A big collection of books on JavaScript that are published free on the web.…

57 comments

IE 10 Specific Styles

Conditional comments are gone in IE 10. That's good. IE 10 is a very good browser. Feature detection is a better way to go in nearly all cases. But what if you find some styling situation where you absolutely need to target IE 10? I guess you'll have to do this.…

Hitch

It's kinda like a preprocessor (variables, prefixing...) but it can do much more because it's JavaScript that executes on your page. For instance, it can give you a has selector which can test if an element contains another element or selectors that select based on simple math logic (e.g. :-math-greatest(data-price)). …

19 comments

Crop Top

Sometimes you want an image to resize responsively but restrict its height — cropping it then as it widens. Here, we explore three options with various trade-offs.
32 comments

Pizza Time Hovers

Hover Maester Jenn Lukas sent me a link to PizzaTime.com. We agreed that 1) those are some pretty neat hovers! and 2) it's pretty cool that there is a quality website at all at a domain like PizzaTime.com - in which that she typed in randomly hoping there would be.…

Request Quest

Jake Archibald put together an interesting and informative quiz about when browsers actually make requests. I learned a bunch. Some of it might seem like quirky academic knowledge but we all know how often unpredictably weird situations come up in day to day dev work.

Jake wished me to point out that it is unfinished (only works on desktop Chrome) and might hurt your feelings if you can't take browser insult jokes.…

The “When Can I Use” Web Widget

A script from Andi Smith that injects a chart of browser support with live data from Can I Use... I really like the idea of using it on any web tech blog post - so the information about feature support stays up to date over time. I think I'll be incorporating it into this site when I get a chance.

Alexis Deveria is cool with it.

It hits a JSON file at raw.github.com through YQL for the data. I …

19 comments

Using requestAnimationFrame

There used to be just one way to do a timed loop in JavaScript: setInterval(). If you needed to repeat something pretty fast (but not as-fast-as-absolutely-possible like a for loop), you'd use that. For the purposes of animation, the goal is sixty "frames" per second to appear smooth, so you'd run a loop like this: …

35 comments

A Couple of Use Cases for Calc()

calc() is a native CSS way to do simple math right in CSS as a replacement for any length value (or pretty much any number value). It has four simple math operators: add (+), subtract (-), multiply (*), and divide (/). Being able to do math in code is nice and a welcome addition to a language that is fairly number heavy.

But is it useful? I've strained my brain in the past trying to think of obviously useful cases. …

Grids with text-align: justify

Patrick Kunka demos how fluid grids can be created with percentage widths and justified text. I like it because you don't need to think about gutter calculations which is what really complicates grids. If you need specific control over gutters, Don't Overthink It Grids might help. …

93 comments

Sass Style Guide

With more people than ever writing in Sass, it bears some consideration how we format it. CSS style guides are common, so perhaps we can extend those to cover choices unique to Sass.

Here are some ideas that I've been gravitating toward. Perhaps they are useful to you or help you formulate ideas of your own. If you're looking for more examples, Sass Guidelines is another good place to look.…

33 comments

3D Button Parallax

The following is a guest post by Alexander Futekov. We recently published an article by Joshua Bader in which a 3D inset look was adjusted as the page scrolled to give it a more realistic interaction. This is similar only Alexander is using an extruded look on buttons and employing a totally different technique.

This Website Brought To You By…

I always wanted to write something on all the technologies that a website relies on in order to have been created and work. My attempts have so far failed because it spirals out of control so quickly. Kevin Kelly sums it up:

A web page relies on perhaps a hundred thousand other inventions, all needed for its birth and continued existence. There is no web page anywhere without the inventions of HTML code, without computer programming, without LEDs or cathode …

38 comments

Logic in Media Queries

Just in case you have brain farts about this constantly like I do.…

5 comments

CSS-Tricks Chronicle XIII

> go east > You see a beautiful grassy field. > set up camper > You camper is now set up [roundtime: 18 seconds] > sit down

Prepros

Is an open-source app modeled after CodeKit. Prepros runs on Windows where CodeKit is Mac only. From people who have tried it, it seems good.…

Chrome’s requestAutocomplete()

Auto-filling forms is nice because it saves time and is less prone to user error. Even better is not even needing to see a form in the first place.…

47 comments

Replace the Image in an <img> with CSS

The following is a guest post by Marcel Shields. Marcel in a difficult place where he needed to change the image on a page but didn't have access to the HTML. Rare, but I'm sure we've all be in weird situations like this. He explains how he managed to replace that image without needing to access the HTML or JavaScript. Also turns out to be a pretty good way to replace anything with an image.