I would like to write “I live on the campus”. I have written it as
J'habite dans le campus
But I have found here “vivre sur le campus” as “live on campus”. I would like to know if my translation is correct.
It is much more common to write and say "J'habite sur le campus.". However, you do find "dans le campus" and it is not really incorrect (ngram).
"Sur" is the préposition generally used for all the usual constructions (ngram);
"Au campus" (à le campus) is used but it seems to be essentially limited regionally to Africa (ref).
"J'habite sur le campus" is just perfect.
"J'habite sur Paris" is awful and incorrect.
"J'habite dans Paris" is fine and means inside the "périphérique".
"Mon logement est situé sur le campus" is fine and "dans le campus" is weird.