High-precision magnetic field measurements are of great significance for the in-depth study of the physical processes in the astrophysical plasma environment. To obtain accurate natural magnetic fields, in-flight calibration is one key step to obtaining zero offset of the spaceborne fluxgate magnetometer (FGM). Mirror mode structures, widely existing in the solar wind and planetary magnetosheaths and magnetospheres, can be used to calculate the zero offset. However, it is difficult to obtain an accurate zero offset by the current methods using mirror mode structures in the planetary magnetosheath. Here, we develop a new method to calculate the zero offset of the spaceborne FGM using magnetic dips, which are a kind of mirror mode structure. This method is based on the assumption that the magnetic field is zero in the cross section of the magnetic dip. Our method is able to calculate the zero offset using only one magnetic dip. We test this method by using the data from the Magnetospheric Multiscale Mission, and find that the calculation errors of 78.1% of the estimated zero offsets are <0.5 nT when using 25 magnetic dips in the terrestrial magnetosheath. This suggests that our method is able to achieve a high accuracy of the zero offset in the planetary magnetosheath.