Osteoporosis (OP) is an important aging-related disease and the effective prevention/treatment of this disease remains challenging. Considering the acidic microenvironment of bone resorption lacunae, herein, we rationally designed two pamidronate (Pami)-derivative and alendronate (Alen)-derivative hydrogelators and which self-assemble into nanofibers to form supramolecular hydrogels under acidic conditions. Cell viability assay, osteoclastogenesis, osteoclastic gene expression, and in vitro bone resorption results indicated that both and have better inhibitory effects on osteoclastic formation and bone resorption than Pami and Alen, respectively. We anticipate that our new drugs and could "smartly" self-assemble and locally concentrate the drugs at bone resorption lacunae in vivo and subsequently prevent/treat osteoporosis more efficiently.