Automatically fit navigation to container by adding appropriate classes