How do I keep an ui element in side of the canvas when scaling?

How do I do it?

You should place the Anchors on the edges of the ui Element.