I have set up a link to an image using fancybox but when I click on the thumbnail the fancybox box appears behind all my content. I have been using z-index to place other content in the page so I think I need to do the same for the fancybox but I don't know where to place the css code?
Fancybox has it's own CSS file, and you should look for #fancybox-wrap
and change it's z-index'es there. But anyways, it has pretty high setting by default (1101 on mine), therefore I'd suggest altering your own HTML/CSS.
Just in case, check if you have added that fancybox stylesheet in your HTML.