Using the CSS below, you can fade an elements opacity in and out by adding and removing the class .hidden

.element {
    -webkit-transition: opacity 400ms ease;
    -moz-transition: opacity 400ms ease;
    -ms-transition: opacity 400ms ease;
    -o-transition: opacity 400ms ease;
    transition: opacity 400ms ease;
    opacity: 1;
}

.element.hidden {
    opacity: 0;
}