The device (2) has a vertical element (10) that is pivotably mounted against a vertical element lower part for fastening the device to a hospital or care bed (1). Two longitudinal elements (20a, 20b) have a guide element at one of axial ends for sliding guidance along the vertical element, where the guide element partly engages the vertical element. A guide region is provided exactly at the vertical element for guiding the guide element. The device is implemented as an assembly separated from a head part (9) and a foot part (8) of the bed. An independent claim is also included for a hospital or care bed comprising a head part.