Archive for category CSS

Google Font API

Just stumbled across the Google Font API- it’s a (at the moment) small directory of open source fonts hosted by google which can be used on your website via their font API. Looking at the quick start it just seems to be a matter of adding an include to your page, then referencing the fonts in your css, like you would any other font. Clever stuff!

No Comments

HTML5 & the Processing.js JavaScript library

Just reading up on html5 and the processing.js javascript library which takes advantage of the new canvas element to do some pretty cool stuff (check out their ‘exhibition’ section) – came across this site which has loads of useful stuff on it.. code.bocoup.com

No Comments

New site launch- natashahampshire.co.uk

Juts launched a new portfolio site for my girlfriend, www.natashahampshire.co.uk – This is just the first phase with a few more features and a bunch of extra contact to be added in the coming weeks, but we needed to get it up ASAP so she can apply for a design course in London!

No Comments

Javascript & CSS Minification

Is that a real word?

Well anyway, I’m just finishing off a fairly jQuery heavy site I’m building for my girlfriend as an online portfolio site and figured I’d minify the css and jQuery to reduce loading times (as all of my javascript includes combined come to around 100k)- found a really good java app writen by Yahoo(!) called the YUI Compressor – I combined all my javascript into one combined.js file then minified it nocking 30k off the file size.  Did the same with css only making a saving of 2-3 k, but every little helps!  Very easy to use, but it means you do have to install the java runtime :(

No Comments

Mastering CSS, Part 1: Styling Design Elements | CSS | Smashing Magazine

Excellent set of links to various cool technique and common CSS problems and their solutions, including the one that always gets me- verical centering!

Mastering CSS, Part 1: Styling Design Elements | CSS | Smashing Magazine.

No Comments

A Handy CSS Debugging Snippet

Found a really handy bit of css for debugging from A Handy CSS Debugging Snippet.

* { outline: 2px dotted red }
 * * { outline: 2px dotted green }
* * * { outline: 2px dotted orange }
* * * * { outline: 2px dotted blue }
* * * * * { outline: 1px solid red }
* * * * * * { outline: 1px solid green }
* * * * * * * { outline: 1px solid orange }
* * * * * * * * { outline: 1px solid blue }

No Comments

Google Code Highlighter

You may have noticed that the little snippets of code I’ve been dropping into these post’s suddenly got a bit swankier looking. This is down to a new javascript tool I found for use on blogs and the like, for highlighting code you post on your pages.

Basically you download the zip file- unzip it and copy the javascripts and css files over, then add a few lines of code to the head of your page;

You then put your code in-between >pre< tags and set a name attribute to “code” and set the class to whatever syntax you have- it has support for a whole bunch of languages including c#, vb, php, javascript, css, sql and a whole bunch of others. You can grab this plug-in from here

The install was easy- but a couple of bits did catch me out- the code sample above was the example they give you in the install page. So I blindly copied over this code to the head of my blog, and copied all the files from the zip file over to my sites js and css folders. I found that html highlighting worked fine and so did c# but vb and sql weren’t happening… It eventually clicked that you need to add the references to the additional syntax types you need as the example only has a line for the CS and XML/HTML “brush” libraries. So I popped those lines in and it worked fine.

The other problem that I had, and indeed still have until I get home to actually edit the code, is compatibility with TinyMCE which is the editor used by default in BlogEngine. I found a couple of articles which might help with this but won’t know till tonight;

As mentioned on the Wiki pages there is also the issue that adding a name value to a pre tag, isn’t valid xhtml.

No Comments

Cool typography tool & CSS Links

Example output from the "Wordle" tag cloud application
Just found this site which creates beautifully laid out tag clouds from raw blocks of text or rss feeds ; Wordle

Spencer, over at youlove.us also showed me a really useful font matrix on the 24ways website, showing type face support across Windows and Mac platforms allowing you to expand which fonts you can confidently use on websites without having to resort to creating graphics or break out sIFR!

No Comments

Multiple domains to reduce site loading times

In yet another effort to increase loading times on inherently graphic heavy websites we stumbled across an article on sitepoint which details a limitation across all web browsers.  The limitation, which is came from a recommendation made in the http standard, states that no more than 2 connections should be made to any one domain name.  So if your website has a bunch images, an html file and some css, your browser will only be able to download two of those at a time.  This only really becomes a problem if you have lots of images to download- if you have two large files coming down at once, that's all your connections in use, so everything else will have to wait.

You can get round this by setting up a bunch of sub-domains, pointing to your site root, in exactly the same was as the www DNS record- just add these as additional host headers in IIS- we've got images.domain.co.uk, styles.domain.co.uk, etc etc as well as the standard www.domain.co.uk, then you just set your image tags to grab all your images as normal, but substitute the www's for "images"- like wise with your css- set your link tags to reference your css at styles.domain.co.u/css/screen.cssfor example.

No Comments

CSS Sprites and a flickering problem in IE6

Working for a large publishering group who, among other things, have a large section dedicated to the sale childrens books, we have a lot of websites with really graphically heavy designs.  Specifically the designers will often put in navigation elements using non standard fonts, which they insist must be used as-is leaving us with only a couple of options;

  • sIFR
    This is a javascript/flash solution which allows you to use any font you want on a website.  It’s very simple to use- you simply add the javascript include to the top of your page, then add the sIFR css classes to the elements you want to be processed by sIFR.  You will also need to open the attached fla file and change the font in there and republish the SWF file.  At run time, the javascript then finds any elements using these classes, grabs their content, then substitutes it with a small flash SWF file, showing your title in your chosen font. 

    This is best used for page headings rather than large blocks of text (due to the processor time required to perform the conversion in real time) and, in my experience, can lead to some CSS based head aches (adding padding or margins where you dont expect it, or generally pushing other elements around) if you have a particuly tight design.

  • CSS Sprites
    Example CSS Sprite image showing both a buttons normal and over states

    This solution isn’t as nice as sIFR, as you are still having to create a graphic for every button, and a graphic for every over state etc.  However with Sprites, you dramatically reduce the download times but putting all your button graphics and all their over states in a single image, and adjusting the offset of which part of the image you see on each button, using CSS.  An example sprite with just a single button can be seen in the image on the right.

    The benefits to this include significantly reduced download times as you don’t have a individual set of headers and footers for each of the individual images- you’re just downloading the one graphic.  This also eliminated the need for pre-loaders (which never seem to make much of a difference anyway!) because as soon as the graphic is loaded, you then have all the graphics for your navigation, and their over state’s in memory.

    So for each button on the site you set the same single image file, but when you set the background image, you also set an offset like so;

    #leftNav #btnHome a {
    	background-image:url(/graphics/leftnav_sprite.gif);
    	background-position:0px 0px;
    	}
    	#leftNav #btnHome a:hover {
    	background-position:0px -26px;
    	}
    

IIS 6 Dialogue, allowing you to add Custom HTTP Headers

We went with the CSS Sprites solution in the end which went in very easily and immidiatly worked under firefox.  We did however see issues under IE6- as we roller over the buttons there seemed to be a lag before they actually redrew the normal images, as though it was downloading the graphic again; which apparently is exactly what was happening.  After a bit of googling around we found this article by Andrew Fledderjohann which had the solution we needed (as well as a few other fixes for apache etc)– a simple addition to the headers supplied by IIS when hosting the site.  In the properties for the site in IIS, add a new Custom HTTP Header called Cache-Control and set the value to

post-check=3600,pre-check=43200

This started working instantly for us totally eliminating the flicker.  You can see the results of this working up on www.franklinwatts.co.uk

No Comments