When the diaphragm relaxes elastic recoil and abdominal musculature reposition the diaphragm again. Deeper respiration brings in the muscles of the chest wall, so that the ribs move too. We must therefore understand the skeleton and muscular system of the thoracic wall. The 12 pairs of ribs pass around the thoracic wall, articulating via synovial joints with the vertebral column - in fact two per rib. The ribs then curve outwards then forwards and downwards and attach to the sternum via the flexible costal cartilages.
Costal cartilages are flexible.
The first rib is rather different, short, flattened above and below and suspended beneath a set of fairly hefty muscles passing up into the neck, the scalene muscles. Between the ribs run two sets of intercostal muscles, the external intercostals running forward and downwards, the internal intercostals running up and back. These two muscle sheets thus run between ribs with fibres roughly at right angles. When they contract each rib moves closer to its neighbours. Because the lowest ribs float, and the first rib is suspended from the scalene muscles contraction of the intercostal muscles tends to lift rib two towards rib 1, and so on.