Recent observations of extrasolar gas giants suggest super-stellar C/O ratios in planetary atmospheres, while interior models of observed extrasolar giant planets additionally suggest high heavy element contents. Furthermore, recent observations of protoplanetary disks revealed super-solar C/H ratios, which are explained by inward drifting and evaporating pebbles enhancing the volatile content of the disk. We investigate in this work how the inward drift and evaporation of volatile-rich pebbles influences the atmospheric C/O ratio and heavy element content of giant planets growing by pebble and gas accretion. To achieve this goal, we perform semi-analytical 1D models of protoplanetary disks, including the treatment of viscous evolution and heating, pebble drift, and simple chemistry to simulate the growth of planets from planetary embryos to Jupiter-mass objects by the accretion of pebbles and gas while they migrate through the disk. Our simulations show that the composition of the planetary gas atmosphere is dominated by the accretion of vapor that originates from inward drifting evaporating pebbles at evaporation fronts. This process allows the giant planets to harbor large heavy element contents, in contrast to models that do not take pebble evaporation into account. In addition, our model reveals that giant planets originating farther away from the central star have a higher C/O ratio on average due to the evaporation of methane-rich pebbles in the outer disk. These planets can then also harbor super-solar C/O ratios, in line with exoplanet observations. However, planets formed in the outer disk harbor a smaller heavy element content due to a smaller vapor enrichment of the outer disk compared to the inner disk, where the very abundant water ice also evaporates. Our model predicts that giant planets with low or large atmospheric C/O should harbor a large or low total heavy element content. We further conclude that the inclusion of pebble evaporation at evaporation lines is a key ingredient for determining the heavy element content and composition of giant planets.