The present application discloses a camera device and an electronic device. Wherein, the camera device includes: a seat body, the seat body includes an accommodating groove; a camera head, at least part of the camera head is located in the accommodating groove; a guide part, arranged in the accommodating groove; a rolling structure, the rolling structure is rollingly connected with the guiding part; , the rolling structure is slidably connected with the guide rail; the driving structure drives the camera to rotate relative to the accommodating groove through the rolling structure. In the present application, by defining the matching structure of the seat, the camera, the guide, the rolling structure and the guide rail, the camera takes the rolling structure as a fulcrum and rotates along the guide rail. The rotation direction of the camera relative to the accommodating groove is limited, and the camera can be rotated at a large angle relative to the accommodating groove through the rolling structure, so it provides an effective structural support for the anti-shake of the camera with a large deflection angle, and the product has a good anti-shake effect. .