Thoroughly clean off all of the soap scum and wait for the surface to dry (otherwise, the bond might fail). Apply a strip of foam tape on each mounting flange, stopping one inch short of the ends.
Once I was satisfied with the layout, I took shelf measurements and marked stud locations to determine the length of each mounting bracket. The post How to Build and Install DIY Floating Shelves ...