figured out what the issue was.
Centering was working fine.
The shaking of the content was due to the vertical scroll bar removal.
when I hit on a button, data gets refreshed. This was causing to remove vertical scroll bar and putting it back when the data came back from server. Since I set the div margin to auto it was trying to center when the scroll bar is removed and came back which was causing the shaking of content in the div.
Fixed it by setting the min-height.