Feed on
Posts
Comments

Some of you have asked for more examples of the PHP pagination class I wrote, specifically the same examples I’m using here on the site. The database comes from
MySQL’s free example databases available at http://dev.mysql.com/doc/#sampledb (my example uses the world database). The two examples I use here can be seen at
http://www.catchmyfame.com/paginator/example.php and http://www.catchmyfame.com/paginator/example-form.php. You can download both PHP files, along with the
pagination class in a zip file. Don’t forget to grab the sample database from MySQL.

Note that the MySQL site seems to be undergoing some updates and the sample databases are hard to find. If the above links don’t work try http://dev.mysql.com/doc/index-other.html

By accident the other day I came across the CSS3 target selector.  If you’re unfamiliar with what pseudo class selectors are, the W3C defines them thusly:

“The pseudo-class concept is introduced to permit selection based on information that lies outside of the document tree or that cannot be expressed using the other simple selectors. A pseudo-class always consists of a “colon” (:) followed by the name of the pseudo-class and optionally by a value between parentheses.”

There are several pseudo classes widely in use today, for example the :visited selector which is normally used like:

a.external:visited

to specify styling of links that have already been visited by the user.

The target pseudo class selector allows us to style parts of the web page that are targeted by bookmark anchor links. Again, I’ll use the W3C for an example:

“Some URIs refer to a location within a resource. This kind of URI ends with a “number sign” (#) followed by an anchor identifier (called the fragment identifier). URIs with fragment identifiers link to a certain element within the document, known as the target element. For instance, here is a URI pointing to an anchor named section_2 in an HTML document: http://example.com/html/top.html#section_2. A target element can be represented by the :target pseudo-class. If the document’s URI has no fragment identifier, then the document has no target element.”

You’re seen these links since the web began, however now we can apply styling based on the specific bookmark anchor. For example, using the URL in the previous paragraph, we could create a style that was only applied to the bookmark anchor section_2 if the URL contained #section_2. An example helps illustrate what I mean. Take a look at this page, but don’t click anything. Feel free to scroll up and down. Nothing special right? Now try clicking one of the links in the page, or go to the page again using this link /downloads/pseudo-target.html#two. Pretty cool. No JavaScript or anything else needed. What happens is that the bookmark anchor you follow gets styling applied to it only when the URL contains the bookmark anchor (e.g. #two, #six, #seven, etc.). The CSS that accomplishes this is:

dt:target {
	color:blue;
	background:#EFEFEF;
	border:1px solid #CCCCCC;
	padding:4px 2px;
	-moz-border-radius: 6px;
	-webkit-border-radius: 6px;
}

dt:target + dd {
	padding:4px;
	color:#336;
	background: #FDFDFD;
	border-bottom: 1px dotted #CCCCCC;
	border-right: 1px dotted #CCCCCC;
	border-left: 1px dotted #CCCCCC;
}

By applying the :target pseudo class selector, we can tell the browser to only style the elements on the page that match the bookmark anchor chosen. Among other things, this allows you to easily style part of a page like a FAQ and highlight the relevant link only when the user has clicked on a bookmark anchor or followed a URL that targets a specific anchor.  How many times have you followed a link that jumps you to a specific part of a long document only to not be sure that you’re seeing what you expected. This is especially true when bookmark anchor links take you to the bottom of a page when the browser can’t pull the content up to the very top of the window (i.e. link one versus link 10 in the demo).

Browser support

Since the :target pseudo class selector is a CSS3 feature, not all browsers understand it, or implement it fully. Firefox 3.5.1 and Chrome 2.x do a great job. Safari 4 almost gets it all right, and IE8 ignores it completely. Opera 9.64 seems to handle the :target selector alright, but ignores the sibling CSS (dt:target + dd).

I’m happy to announce that jQuery Infinite Carousel 1.0.1 has been released. This new version, which can be downloaded from the jQuery Infinite Carousel page, fixes a few bugs, adds a new feature, and comes in a reorganized zip file with a demo.

Changes:

  • Bug fixed for caption box height for large values
  • Default format for captions is now HTML instead of text
  • Images now in their own folder
  • Demo added
  • Documentation updated

Over the years I’ve needed a quick reference for CSS shorthand properties for things like font, border, and background. While there are a few decent cheat sheets out there for this, inevitably I end up having to pull them off my wall and read them because they aren’t clear enough. I finally decided to make my own and I’m making it available to anyone who wants it. It’s a one page PDF which should fit nicely in a wall or binder. It covers the three properties I mentioned above since I find myself using them the most. While it’s true that there are more CSS properties that can be written in shorthand, I find that they’re either a) easy to remember (e.g. color:  #123 versus color: #112233) or they’re infrequently used (e.g. outline?). If you notice any errors please feel free to let me know and I’ll update the sheet.

CSS Shorthand Cheat Sheet in PDF format, or as a PNG image.

CSS Shorthand Cheat Sheet

First of all, apologizes for the unplanned disappearance of this site (and a few others I run). Apparently a post or two received a lot of attention from reddit.com which caused our host to pitch a fit and shut our sites down. Lovely people. Knee-jerk reactions like this are always fun to fix. From what I’ve heard a lot of hosts have this type of shoot first ask questions later policy.

So what happened? On Thursday our site caused the server we’re on to get hammered and this must have set off some sort of alarms at our hosting provider. Now rather than look into the problem and do some basic troubleshooting, we were summarily moved from our old server to the stabilization server. However as our host now admits, they botched that up and didn’t move our databases over which caused the site to become dead. So for the past two days I’ve been going back and forth with them via email, their ticket system, and yes by phone. All that needed to be done was add a caching plugin to our site that got hammered and we should’ve been golden. However to do this, I needed web access to my site and functional databases, neither of which my host could seemingly provide.

For the time being we seem to be functional and hopefully we’ll be around for the foreseeable future. Thanks for your patience; mine are long gone.

« Newer Posts - Older Posts »