Try to keep them to the front of the shelf, at least flush with the front of the shelf. If it sounds boomy, you could try to line the back of the shelf with some acoustic insulation covered in a nice cloth. It may just be trial and error to arrive at the best solution for an imperfect situation.