With the widespread application of antibiotics in the medical field, associated wastewater pollution has become a critical environmental issue, creating potential risks to ecosystems and public health. This study synthesized three novel nanocomposite materials, ZIF-8@h-BN-X, using an in-situ growth method by adjusting h-BN content. Compared to pure two-dimensional hexagonal boron nitride (h-BN), their adsorption capacities for ofloxacin (OFL) in solution were evaluated. Results showed that zeolitic imidazolate framework-8 (ZIF-8) attached and grew on the h-BN surface, altering surface functional groups and significantly enhancing the nanocomposite's adsorption effect on OFL. Adsorption capacity depended on the initial h-BN content, with lower X content resulting in more active sites and stronger adsorption capacity. Equilibrium adsorption capacities were 145.46, 124.91, and 58.16 mg·g