- The dynamics of electrons in the presence of E and B field gradients is considered. The results are applied to electron heating in quasi-perpendicular shocks. The main focus is on the transitions between adiabatic and overadiabatic heating and from perpendicular to oblique geometry. Contrary to previous results, it is shown that the divergence of initially close electron trajectories always takes place in the quasi-perpendicular collisionless shock front. In the case of negligible electric field gradients at the shock front, the divergence rate depends only upon the magnetic field gradient and results in adiabatic heating. If the electric field gradient is not negligible, divergence rate depends on increasing electric field gradients. In this case, the divergence rate in the first part of the ramp will exceed the ``adiabatic'' divergence rate. This enhancement is significant for scales of the electric field of about 4-6c/omegape. Under the conditions of the Earth's bow shock the magnetic field and particularly its gradients affect the electron trajectory divergence rate and thus the process of thermalization of electrons.