Loess has loose metastable structure, which is not difficult to be destroyed under load. As the core and soul of loess structure, it is part of the main research directions of loess engineering properties at present to study its microscopic behaviors and then realize the interpretation and prediction of macroscopic mechanical properties. In this study, based on the analysis of the basic physical properties of loess samples from seven different places, each sample was scanned by X-ray with continuous slice CT, and the three-dimensional microstructure of loess samples was established. According to the computer graphics method, each particle is equivalent to an ellipsoid, and the flattening rate and elongation rate of particles in each sample are quantitatively counted. Taking the particle size distribution (PSD) and shape parameters (flatness and elongation) of each sample as the control factors for generating discrete element method (DEM) samples, a series of triaxial compression simulation tests were carried out, and the microscopic behaviors of each sample were studied within the whole test framework. Comparing the results of seven different samples, it is shown that both PSD and particle shape have effects on stress-strain relationship, dry density and the normal contact force of loess samples. Most of the sand particles (> 0.075mm) are flat particles, while the clay particles (< 0.005mm) are mainly near spheres. When the volume fraction of sand particles is large, the dry density of the sample is the lowest. However, when the content of near spherical clay particles is large and the particle size distribution is good, and the average coordination value is large, which shows that it has strong normal contact force, and thus higher shear strength.