Fonts in Mobile Safari
Here’s some good info about using @font-face in Mobile Safari.
http://blog.typekit.com/2010/04/05/experimenting-with-web-fonts-on-the-ipad/
Here’s some good info about using @font-face in Mobile Safari.
http://blog.typekit.com/2010/04/05/experimenting-with-web-fonts-on-the-ipad/
Ever want to select only the first element in a list? What about the last element? Or how about odd or even element? What about every 3rd element? Or, what about selecting the first 3 elements or the last 3 elements?
Of course you do, and if you haven’t wanted to do this in the past you will want to do in the future at some point, probably sooner than you think.
You can approach the problem with classes, by adding a special class to say the first three elements or every other element. But this becomes very tedious and lacks flexibility. A better solution would be a CSS selector. Well here it is :nth-child(). The :nth-child() selector allows you to accomplish the following.
Imagine for these examples that you have a page with 9 divs, each with the class name box. To select all of these you’d use: .box I’ll modify this selection with :nth-child() in the examples below to illustrate how it works.
These first three examples use :nth-child() in it’s most basic an obvious form. Include the integer position of the element or a key word, odd or even.
Here’s a few more examples.
Here you can think of n as an integer 1, 2, 3 etc. multiplied by the number on the left. So 3n would be 3, 6, 9 etc. There’s more, how these examples.
You can think of the last example: .box:nth-child(n+5) as .box:nth-child(1n+5). Which might make more sense.
Here we’re using an+b. Where elements are selected as a*n+b. Which works out as the following for 3n+5
The last example above .box:nth-child(n+5) would select all of the elements after the first 4. To select only the first 4 elements you can use :nth-child() in this way:
Think of this as:
An alternative to :nth-child() is :nth-last-child(). Which works in the same way, but starts counting backwards from the last element.
What could you use this for? Here are a few ideas:
Who knew, the W3Schools site always looked so “official.”
Someone just brought LESS to my attention. LESS is a Javascript library that extends the functionality of CSS. LESS effectively adds variables and functions to your CSS. Usng LESS you can define variables and apply mathematical functions to your values in your stylesheets.
For more information read more on their web page: LESS.org
The JQuery .css() method provides a function to set CSS properties and values for any element. The .css() method will also retrieve the value of any CSS poperty for any element.
To set a CSS property use of the of the following methods.
.css(property,value);
Using this system set the property as the first parameter and the value as the second. Both parameters should strings. Use the standard CSS property names, the same as used in your CSS style sheet. For example:
$('p').css('color', '#F00');
The line above would find all p tags on a page and set the color to red.
Sometimes you may want to set multiple properties at once. In these cases use this syntax.
.css({prop:value,prop:vlaue,...});
In this case pass one parameter, an object containing all of the properties and values to be set. Since property names set in the object can not contain special characters you’ll need to alternate property names. For example normally you would use background-color in your CSS style sheet. When using an object property list the – (hyphen) is not allowed. Instead use: backgroundColor. Notice I removed the unacceptable character and began the next word with an uppercase letter. For example:
$('p').css({lineHeight:'18px',letterSpacing:'0.1em'});
The example above sets the line height and letter spacing of all p elements.
Alternately, the CSS property name can be used as long as it is wrapped in quotes. For example the line above could alternatively be written as:
$('p').css({'line-height':'18px','letter-spacing':'0.1em'});
The value of any property may also be retrieved. For example, imagine you wanted the font-size of one element to match the font-size of another.
$('li').css('font-size', $('#headline').css('font-size') );
The line above sets the font size of all li elements to the same font-size as that of the element with the id name #headline.