The properties of $^{12}\mathrm{C},\phantom{\rule{0.16em}{0ex}}^{16}\mathrm{O}$, and $^{20}\mathrm{Ne}$ nuclei in strong magnetic fields $B\ensuremath{\simeq}{10}^{17}$ G are studied in the context of strongly magnetized neutron stars and white dwarfs. The sky3d code is extended to incorporate the interaction of nucleons with the magnetic field and is utilized to solve the time-independent Hartree-Fock equations with a Skyrme interaction on a Cartesian three-dimensional grid. The numerical solutions demonstrate a number of phenomena, which include a splitting of the energy levels of spin-up and -down nucleons, spontaneous rearrangement of energy levels in $^{16}\mathrm{O}$ at a critical field, which leads to jump-like increases of magnetization and proton current in this nucleus, and evolution of the intrinsically deformed $^{20}\mathrm{Ne}$ nucleus toward a more spherical shape under increasing field strength. Many of the numerical features can be understood within a simple analytical model based on the occupation by the nucleons of the lowest states of the harmonic oscillator in a magnetic field.