Elgar hit 103 in 187 balls, reaching his century with a six, before South Africa closed on 268 for five.
He said coming to terms with conditions following a cold winter in South Africa meant he was tested during his time at the crease.
"The heat is quite a factor," Elgar said.
"I have come from a cold South African winter and have been hit with a culture shock in 30 degree temperatures."
Elgar scored two centuries and 431 runs overall when South Africa 'A' toured Sri Lanka in 2010, and he drew on that experience during his innings.
"I have had experience in Sri Lanka before so I knew what to expect from the conditions.
"Towards the end it did get quite tough, and to make it tougher their bowlers also gave us nothing. I had to find a way to get through it."
He added 125 for the second wicket with Faf du Plessis, who he has now shared four century partnerships with.
"Faf and I get along really well, and on the field we seem to get on even better.
"We have had some good batting partnerships together, we know what we are about and what makes us tick.
"Luckily we communicate quite well out there," he added.
However, although Elgar's knock put South Africa in a strong position, they lost four wickets in the final session to leave the game evenly poised.
Elgar gives credit to Sri Lanka's bowlers but believes the Proteas have the firepower to still post a score in excess of 400.
"We would have loved to have been three down at stumps with the score we have," he said.
"There is still a lot of graft and we have batters in the shed. We have Quinny (de Kock), Koppe (Duminy), Vernon (Philander) and Dale (Steyn) to come, all these guys can score runs.
"We have to edge closer to that mark that we have spoken about. It's going to be hard work, it's going to be tougher tomorrow, especially with the wicket deteriorating."
© Cricket World 2014