If the parents don't follow the rules, how would the kids? Crooked upper beam, warped lower beam.
Tips
history
Traced to 晋·杨泉《物理论》 (Yáng Quán's 'Wùlǐ Lùn', Jin dynasty): 上不正,下参差 (shàng bú zhèng, xià cēncī) 'when the top is not straight, the bottom is uneven'. The longer beam-imagery version became proverbial in vernacular Chinese.
memory
Visualize a wooden house frame: if the top crossbeam (上梁 shàngliáng) tilts, the lower beam (下梁 xiàliáng) ends up warped (歪 wāi 'crooked, askew'). Used to scold parents/bosses/leaders whose subordinates have picked up their bad habits.