The dynamical mean-field-like theory of the electron spin resonance (ESR) in spin-1/2 chains with nearest and next-nearest neighbor interactions (or zigzag spin ladders) and alternation is developed. It is explained that either the magnetic anisotropy of spin-spin couplings or the Dzyaloshinskii-Moriya interaction causes shifts of the resonance position in spin chains, comparing to only magnetically isotropic interactions. The power of the ac ESR field, absorbed by the spin chain, is calculated. It is shown that the temperature dependence of the shift of the resonance position is related to the temperature dependence of the ESR absorption. Depending on the strength of next-nearest neighbor interactions, the shift of the ESR position can become either exponentially small or can be increased near quantum critical points. The absorbed by the alternating spin chain power of the ac magnetic field is calculated, manifesting two resonances. The influence of mentioned spin-spin interactions on the linewidth of the ESR is analyzed.