Blog

Archive for the ‘Web Development’ Category

How to generate a favicon icon for IE7 and gecko browsers

Saturday, May 31st, 2008

Recently I had an issue trying to get a certain favicon to show up in IE7. It turns out the favicon.ico file I was using was not valid! Now I can’t remember where I generated it from, there are a number of sites out there. So here’s the steps you need to take to create a working favicon in ie7 and other modern browsers.

To set up a favicon on your site:

  1. Create a 32pxX32px or 16pxX16px gif of the image you want (I usually go with 16). Favicons usually work best if they are squared-out.
  2. Next go to http://www.chami.com/html-kit/services/favicon/ ( or any other site, but I find this one created the valid one I needed to get it working in ie7)
  3. Next add this line of code inside the <head> tag of your site:
    <link href=”http://your-website/images/favicon.ico” rel=”icon” type=”image/x-icon” />
    <link href=”http://your-website.com/images/favicon.ico” rel=”shortcut icon” type=”image/x-icon” />
  4. Next you will want to validate your icon here: http://www.html-kit.com/favicon/validator/
  5. Be sure that if your updating an icon or replacing one that you clear your cache: Clearing ie7 cache instructions found here: http://help.isu.edu/index.php?action=knowledgebase&catid=38&subcatid=64&docid=1015

Useful CSS2 and CSS3 Selectors and Psudeo Classes

Wednesday, April 23rd, 2008

I put together a list of some nice css selectors.

More Browsers are starting to support CSS3.

Multiple background images for one element

  1. .box {
  2. background-image: url("top-left.gif"), url("top-right.gif"), url("bottom-left.gif"), url"(bottom-right.gif");
  3. background-repeat: no-repeat, no-repeat, no-repeat, no-repeat;
  4. background-position: top left, top right, bottom left, bottom right;
  5. }

Source: 24 ways

Media Querie

This Media Query expresses that the style sheet is usable on devices with viewport (the part of the screen/paper where the document is rendered) widths between 400 and 700 pixels:”

  1. @media screen and (min-width: 400px) and (max-width: 700px) {
  2. property:value;
  3. }

This Media Query expresses that style sheet is usable on screen and handheld devices if the width of the viewport is greater than 20em.

  1. @media handheld and (min-width: 20em) {
  2. property:value;
  3. }

Source: wc3

Sibling Selectors

Sibling Selectors will make it easy to style elements without having to add so much markup. Extra divs would not no longer necessary.

Child Selector (CSS2)

Matches all li’s that are immediate children of the ul.

  1. ul>li {
    property:value;
    }

Adjacent Sibling Selector(CSS2)

This example targets the p when h2 is an adjacent sibling.

  1. h2+p {
    property:value;
    }

General Sibling Selector (CSS3)

This example will match a p element if it’s a sibling of an h2 element

  1. h2~p {
    ⋮ property:value;
    }

Pseudo Elements

Some of these are really cool, it’s more posssible to target almost any element without using classes or wrappers.

  1. :first-letter
    represents the first character of the first line of text within an element

  2. :first-line

    represents the first formatted line of text

  3. :before

    specifies content to be inserted before another element

  4. :after

    specifies content to be inserted after another element

  5. ::selection

    represents a part of the document that’s been highlighted by the user

Psuedo Classes

  1. :nth-child(N)
    matches elements on the basis of their positions within a parent element’s list of child elements

  2. :nth-last-child(N)

    matches elements on the basis of their positions within a parent element’s list of child elements

  3. :nth-of-type(N)

    matches elements on the basis of their positions within a parent element’s list of child elements of the same type

  4. :nth-last-of-type(N)

    matches elements on the basis of their positions within a parent element’s list of child elements of the same type

  5. :last-child

    matches an element that’s the last child element of its parent element

  6. :first-of-type

    matches the first child element of the specified element type

  7. :last-of-type

    matches the last child element of the specified element type

  8. :o nly-child

    matches an element if it’s the only child element of its parent

  9. :o nly-of-type

    matches an element that’s the only child element of its type

  10. :root

    matches the element that’s the root element of the document

  11. :empty

    matches elements that have no children

  12. :target

    matches an element that’s the target of a fragment identifier in the document’s URI

  13. :enabled

    matches user interface elements that are enabled

  14. :disabled

    matches user interface elements that are disabled

  15. :checked
    Pseudo-class
    matches elements like checkboxes or radio buttons that are checked

  16. :not(S)

    matches elements that aren’t matched by the specified selector

Source: Sitepoint