Magnets attract many metal items, such as iron filings, but they can also repel each other. What many people seldom notice, however, is that many everyday items are weakly repelled by a magnetic field. The reasons why magnets attract some items and repel others stem from differences in molecular and atomic structure.
Electrons are subatomic particles that behave like miniature magnets. They have a property called spin and can be either spin up (+1/2) or spin down (-1/2). Two electrons in the same orbital always have opposite spins, so when they are paired, their magnetic fields cancel out. In metals, the situation is more complicated, because electrons are delocalized, or shared between multiple atoms, but in general, materials of this kind are called diamagnetic, meaning they are weakly repelled by a magnetic field.
Common Diamagnetic Materials
Most materials are diamagnetic. Water, wood, people, plastic, graphite and plaster are all examples of diamagnetic materials. While we usually think of these materials as non-magnetic, they actually repel (and are repelled by) a magnetic field. This repulsion is extremely weak, so weak that in everyday life, it's negligible. With a strong magnetic field, however, this repulsion is sufficient to levitate some small items and objects. One scientist at the University of Manchester was able to levitate a frog and a tomato--both diamagnetic objects--using a powerful magnetic field. His work won him an Ig Nobel prize, an award dedicated to silly science.
Most items around your home weakly repel magnets, but unless the magnetic field is very strong, you'll never notice the effect. To really repel a magnet, you need another magnet. All magnets have two poles, north and south. Just as with electric charges, the rule is that similar charges repel while opposite charges attract. A magnetic south pole is attracted to a magnetic north pole, but north on north or south on south repel each other. You can get a feel for how this works if you try holding two magnets together--in one orientation they repel each other, while in the other they attract.
Another kind of repulsion can occur between a magnet and a coil of wire. The amount of magnetic field passing through a wire coil is called the magnetic flux. Any time there is a change in the flux, it induces a current whose magnetic field acts in opposition to the change in flux. This rule is called Lenz's Law. Moving a coil of wire into a magnetic field causes repulsion between the coil of wire and the magnet. That's because the flux through the coil is increasing, so a current is induced in the coil. From Lenz's Law, we know the current induced in the coil creates a magnetic field opposing the increase in flux, thereby creating a repulsion between the coil of wire and the magnet from which the field emanates.