This ancient ballad "Sir Patrick Spens" depicts the Anglo/Saxon intense attraction to and curiousity for the sea. While a life at sea was romantic to many, the truth was that it was a difficult, painful, and dangerous life.
As the poem goes, the captain, Patrick Spens, did not want to take the voyage as the moon indicated bad weather and bad fortune. Unfortunatly, away they went. The line you indicate means, when translated, "their hats swam above." This means that the only thing left of the men on the boart was their floating hats.
The ship sank; the men died.