Molecular imprinting is recognized as a powerful technique for preparing polymeric structures that contains tailor-made recognition sites for certain molecules. By combining a responsive hydrogel photonic crystal and molecular imprinting of 3-pyridinecarboxamide, polyacrylamide (PAM) imprinted photonic crystals (IPCs) with an inverse opal structure were prepared. They showed a rapid, recoverable, and selective response to 3-pyridinecarboxamide, which was detected by measuring the diffraction peak. The position of the diffraction peak could be tuned by copolymerizing acrylamide (AM) with acrylic acid (AA), by changing the ratio of AM to AA, by adding N,N′-methylene bisacrylamide to the monomers, or by imprinting molecules to monomers. More interestingly, the change in the Bragg diffraction of the IPCs can be directly converted into a readable optical signal that is visible to the naked eye without any labeling treatment.