In this work, the compressive buckling of a nanowire partially bonded to an elastomeric substrate is studied via finite-element method (FEM) simulations and experiments. The buckling profile of the nanowire can be divided into three regimes, i.e., the in-plane buckling, the disordered buckling in the out-of-plane direction, and the helical buckling, depending on the constraint density between the nanowire and the substrate. The selection of the buckling mode depends on the ratio d/h, where d is the distance between adjacent constraint points and h is the helical buckling spacing of a perfectly bonded nanowire. For d/h > 0.5, buckling is in-plane with wavelength λ = 2d. For 0.27 < d/h < 0.5, buckling is disordered with irregular out-of-plane displacement. While, for d/h < 0.27, buckling is helical and the buckling spacing gradually approaches to the theoretical value of a perfectly bonded nanowire. Generally, the in-plane buckling induces smaller strain in the nanowire, but consumes the largest space. Whereas the helical mode induces moderate strain in the nanowire, but takes the smallest space. The study may shed useful insights on the design and optimization of high-performance stretchable electronics and three-dimensional complex nanostructures.