Yes. Viral infections are common in pregnancy and can cross the placenta. Handwashing, avoiding ill people and the mother's immune system are key in protecting the baby. In general, viral illnesses in the early part of the pregnancy are less likely to cross the placenta but more likely to affect the baby than viral infections in the later half.
Some do, some don't. If you get a cold, or otherwise localized virus it will stay in the area involved & not enter your blood (or baby). If you have a virus that enters your blood, like measles or the flu it will be shared with the baby & the outcome will vary with the type of germ. Some localized viruses, like recurrent genital herpes could be transmitted externally during the birthing process.