Wrongly believing himself to be offside, the French striker stopped when given a clear run on goal, and when he belatedly realised that the assistant referee had kept his flag down, Steven Caulker rushed back to block.
Fortunately for Giroud, Ramsey was on hand to spare his blushes in the 29th minute.
The Welsh midfielder sent a superb header past David Marshall from Mesut Ozil's cross, and his refusal to celebrate against his former club prompted a round of applause from the entire stadium.
Cardiff have already beaten Manchester City at home this season and drew 2-2 with Manchester United last weekend, and they came to close to equalising in the second half when Wojciech Szczesny had to claw away a Fraizer Campbell header.
But Flamini settled the visitors' nerves in the 86th minute, gathering a pass from Ozil and lashing home, before Ramsey continued his astonishing form by claiming an emphatic second goal in stoppage time.
Barcelona loanee Gerard Deulofeu produced a dazzling individual display as Everton crushed Stoke 4-0 to move level on points with Liverpool and Chelsea.
The 19-year-old Spanish forward opened the scoring on the stroke of half-time, exchanging passes with Steven Pienaar and then Gareth Barry before slamming a shot past Asmir Begovic at his near post.
Seamus Coleman added a second early in the first half from Deulofeu's left-wing cross, before Bryan Oviedo _ a replacement for the injured Leighton Baines _ made it 3-0 with a crisp 25-yard drive.
On-loan Chelsea forward Romelu Lukaku sealed victory with a 79th-minute tap-in from an Ovideo cross.
Elsewhere, Tony Pulis's first game as Crystal Palace manager ended in a 1-0 defeat at Norwich City that saw the London club sink to the foot of the table.
Gary Hooper scored the only goal at Carrow Road in the 30th minute, coolly slotting home after Johan Elmander's centre was steered back across goal by Wes Hoolahan.
Sunderland saw Emanuele Giaccherini miss a sitter and Fabio Borini hit the bar in a 0-0 draw at Aston Villa, but the point was sufficient to take Gustavo Poyet's side off the bottom at Palace's expense.
Third-bottom Fulham are now three points adrift of safety, after second-half goals from Mohamed Diame, Carlton Cole and Joe Cole saw them slump to a fifth straight loss in a 3-0 defeat at London rivals West Ham United.
Newcastle United host West Bromwich Albion in the day's late game, when victory would be enough to take the home side up to fifth place.