Here is Canvas object wihch demonstrate the problem.

These bending moments cause the beam to flex as shown. The portion of the beam above the z centroidal axis is compressed while the lower portion is elongated.

Investigating shear in beams