<sec>Heavy-ion collisions can produce high-temperature and high-density quantum chromodynamics (QCD) matter under extremely strong electromagnetic fields, which triggers off many important anomalous chiral phenomena, such as the chiral magnetic effect and chiral magnetic wave. The anomalous chiral phenomena can help to find the evidence of <inline-formula><tex-math id="M2">\begin{document}$\cal{CP}$\end{document}</tex-math><alternatives><graphic xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="11-20230245_M2.jpg"/><graphic xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="11-20230245_M2.png"/></alternatives></inline-formula> symmetry breaking in the strong interaction, deepen the understanding of the QCD vacuum fluctuations, and disclose the mystery of asymmetry of antimatter-matter in the universe. </sec><sec>In this paper, firstly, the magnetic fields are investigated for small and large colliding systems at relativistic heavy ion collider (RHIC) and large hadron collider (LHC). These studies indicate that collision energy and initial nucleon structure have significant effects on magnetic fields. And, the lifetimes of magnetic field in different media are very different in heavy-ion collisions. Then, in order to study the chiral magnetic effect, some experimental observables are studied by using a multi-phase transport model without or with different strengths of the chiral magnetic effect. For small systems, if QGP exists, the chiral magnetic effect could be observed in the peripheral collisions. For isobaric collisions, the correlators with respect to the spectator plane can imply a much cleaner signal of chiral magnetic effect than that with respect to the participant plane. Our results support that the strength of chiral magnetic effect may be absent or small in isobaric collisions. Next, some new strategies are applied to study the chiral magnetic wave. Moreover, a novel mechanism for the electric quadrupole moment can also explain the charge-dependent elliptic flow of pions generated by the chiral magnetic wave. In addition, some interesting phenomena also occur, owing to the magnetic field in heavy-ion collisions at intermediate energy. The directed flow and elliptic flow of photons have no effect on magnetic field at <inline-formula><tex-math id="M3">\begin{document}$p_{\rm T}<25$\end{document}</tex-math><alternatives><graphic xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="11-20230245_M3.jpg"/><graphic xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="11-20230245_M3.png"/></alternatives></inline-formula> GeV. However, because of the magnetic field, the directed flow of photons decreases and the elliptic flow of photons increases at <inline-formula><tex-math id="M4">\begin{document}$p_{\rm T}>25$\end{document}</tex-math><alternatives><graphic xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="11-20230245_M4.jpg"/><graphic xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="11-20230245_M4.png"/></alternatives></inline-formula> GeV. Besides, the magnetic field has a significant effect on giant dipole resonance, i.e. the magnetic field increases the angular momentum and enhances some observables of the giant dipole resonance spectrum. In conclusion, magnetic field plays a key role in heavy-ion collisions at both high energy and intermediate energy. It provides an unprecedented opportunity for studying the microscopic laws of nuclear physics. However, there are still many unsolved problems that need further studying in the future.</sec>