© Getty Images
The away side almost took the lead after just two minutes when Jack Wilshere collected the ball from Ramsey outside the box, before unleashing a wild shot that cannoned back off the crossbar.
Arsenal were in control of possession throughout the half and they finally took the lead through Ramsey, who got onto a cross from Mesut Ozil to head home, leading to muted celebrations from the Welshman.
© Getty Images
Campbell had an excellent chance to bring the game level after the interval, but his header into the ground was somehow kept out by an athletic Wojciech Szczesny.
Don Cowie came into the game as the home side searched for an equaliser by playing in Theophile-Catherine, but the midfielder's shot was easily pouched by Szczesny.
Arsenal sought to increase their lead following a Cardiff flurry, but Giroud's curling effort couldn't find the top corner as David Marshall made the save.
The Frenchman was wasteful again, this time as Wilshere broke away on the counter before feeding the striker, whose effort flew high and wide with Cardiff looking shaken.
Wilshere, arguably Arsenal's most creative player in the game, looked menacing as he found Santi Cazorla who couldn't manage much more than a tame effort straight at the goalkeeper.
However, Arsenal finally put the game to bed through the most unlikely of goal-scorers as Flamini converted from the centre of the box having been put through by Ozil in the 86th minute, before Ramsey grabbed his second of the game in injury time.