Added active class and fixed bug with CSS transitions