Change your CSS to following
table, th, td { border:1px solid black; }
tr{ transition: background 2s ease-in-out; }
.selected { background-color: LightBlue; }
Also make sure you use -webkit, -moz, etc for best compatibility
(1) why the fade-out is abrupt - Because as per your CSS, '.selected' will have the transition only (2) how I can make the fade-out gradual? - give transition property to tr