Elgar made 128 not out, his ninth Test century, and put on 196 for the first wicket with debutant Aiden Markram, who was run out for 97 as the Proteas closed on 298 for one.
Hashim Amla was unbeaten on 68 after he and Elgar added 102 for the second wicket.
Home captain Faf du Plessis could not hide his surprise after his Bangladesh opposite number Mushfiqur Rahim won the toss and asked the hosts to bat first.
Du Plessis said at the toss he was "very surprised" by Rahim's decision. "It looks a little bit dry. I definitely would have batted. It looks a really good pitch and I expect it to spin later on."
More From This Section
There was none of the early life that Rahim had hoped would assist his three seam bowlers.
His only specialist spinner, Mehidy Hasan, was brought in as early as the sixth over.
The pitch played easily all day, although the dry nature of the surface was shown by some balls which kept low. Bangladesh soon settled for defensive fields and they were able to keep the scoring rate under control.
Elgar and Markram were largely untroubled as they ticked off several milestones.
Markram, 22, who captained South Africa to the 2014 Under-19 World Cup title, was Elgar's fourth opening partner of the year and together they posted South Africa's first half-century start in 16 innings before converting it into three figures shortly after lunch, the first century opening stand since December.
Markram made 97 off 152 balls, with 13 fours, before there was a mix-up when both players were approaching their centuries in what proved to be the last over before tea.
Two balls later, Elgar reached his century off 176 deliveries.
South Africa's dominance continued when Amla joined Elgar, although Elgar's scoring dried up in the last hour as he appeared to be battling with cramp.
The closest a Bangladesh bowler came to taking a wicket was when part-timer Sabbir Rahman could not hold a ferocious straight drive from Amla when the batsman was on 40.
Markram's 97 was the highest score for a batsman run out in his first Test innings. Abdul Kadir of Pakistan (95) and West Indies' Gordon Greenidge (93) were also run out in the nineties.