Relativistic heavy-ion collisions can produce extremely strong magnetic fields in the collision regions. The spatial variation features of the magnetic fields are analyzed in detail for non-central Pb–Pb collisions at LHC at , 2760 and 7000 GeV and Au–Au collisions at RHIC at , 130 and 200 GeV. The dependencies of magnetic field on proper time, collision energies and impact parameters are investigated in this paper. It is shown that an enormous and highly inhomogeneous spatial distribution magnetic field can indeed be created in off-centre relativistic heavy-ion collisions in RHIC and LHC energy regions. The enormous magnetic field is produced just after the collision, and the magnitude of magnetic field of the LHC energy region is larger than that of the RHIC energy region at small proper time. It is found that the magnetic field in the LHC energy region decreases more quickly with the increase of proper time than that of the RHIC energy region.