Set margins dynamically