Gradient Text

This is WebKit only, but is the cleanest way to accomplish it as the text remains editable and selectable web text.

h1 {
  font-size: 72px;
  background: -webkit-linear-gradient(#eee, #333);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
Example…
Avatar of Chris Coyier
Chris Coyier on (Updated on )

Subdirectories URL Internally Redirect to Query String

The URL in the browser would be:

https://css-tricks.com/index.php/teachers/a/

The actual page rendered by the server would be:

https://css-tricks.com/index.php?search=teachers&sort=a

RewriteEngine on
RewriteRule ^index/([^/]+)/([^/]+).php /page.php?search=$1&sort=$2 [NC]
Avatar of Chris Coyier
Chris Coyier on

Add Spaces to Dock in OS X

This is absolutely not HTML related, but by sheer demand, I needed to add it somewhere. To add a “space” to the dock in OS X, open up Terminal.app and enter this. Enter it as many times as you want …

Avatar of Chris Coyier
Chris Coyier on

iPad-Specific CSS

@media only screen and (device-width: 768px) {
  /* For general iPad layouts */
}

@media only screen and (min-device-width: 481px) and (max-device-width: 1024px) and (orientation:portrait) {
  /* For portrait layouts only */
}

@media only screen and (min-device-width: 481px) and 
Avatar of Chris Coyier
Chris Coyier on (Updated on )

CSS Run-in Display Value

CSS has a value for the display attribute called run-in. It’s like this:

h3 {
  display: run-in;
}

The point is to allow a header to run into text below it, without sacrificing semantics or running into the problems you …

Avatar of Chris Coyier
Chris Coyier on

Multiple File Input

File inputs can have an attribute of “multiple” which then allows multiple files to be selected in the file section dialog box. Firefox 3.6+ and WebKit browsers only are supporting it so far. Unfortunately the “multiple files” need to be …

Avatar of Chris Coyier
Chris Coyier on

Detect First Visible Element of Certain Class

Adds a class of “first” to the first element that has a class of “activity” that is visible in the browser window.

$(window).scroll(function(){
	var scrollTop = $(window).scrollTop();
	var windowHeight = $(window).height();		
	var first = false;
	$(".activity").each( function() {
		var offset 
Avatar of Chris Coyier
Chris Coyier on (Updated on )