Yes you can build on top of a resource.
You will get access to the resource as soon as you get the tech that is normally required to access the resource. So for copper or iron, you need mining, which is no problem since it's a pre-req, but for something like stone or marble, you would need masonry before the bonuses from the resource would apply.
You do not get the bonuses of actually building a mine/quarry/farm/pasture on the resource. So if a mine would normally add +2 shields to an iron spot, by placing your city on it, you would only get the base city food/shields/commerce and not the amount you would get if you improved the tile somewhere other than your city.
Hope that makes sense.