# How can I make control node margins adjust to the window resolution?

**URL:** <https://forum.godotengine.org/t/how-can-i-make-control-node-margins-adjust-to-the-window-resolution/11024>\
**Category:** Archive\
**Created:** [July 9, 2021, 7:22pm UTC](https://forum.godotengine.org/t/how-can-i-make-control-node-margins-adjust-to-the-window-resolution/11024 "2021-07-09T19:22:17Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://forum.godotengine.org/uploads/default/original/2X/4/4b0a7fa8a6334634b94a13d421f0d99e6f04e21f.svg) [@system](https://forum.godotengine.org/u/system)\
**Post date:** [July 9, 2021, 7:22pm UTC](https://forum.godotengine.org/t/how-can-i-make-control-node-margins-adjust-to-the-window-resolution/11024/1 "2021-07-09T19:22:17Z")

</div>

| | | |
| --- | --- | --- |
| ℹ | **Attention** | Topic was automatically imported from the old Question2Answer platform. |
| 👤 | **Asked&nbsp;By** | Cogan |

When the window resolution changes, I would like the margins to stay the same. Right now, if i adjust the window size, a part of the control node is cut off. I would like for the control node to readjust its size based on the margins. Changing how the screen expands will not work in this situation. All of my attempts so far have been unsuccessful.

---

<div class="post-metadata">

**Author:** ![system](https://forum.godotengine.org/uploads/default/original/2X/4/4b0a7fa8a6334634b94a13d421f0d99e6f04e21f.svg) [@system](https://forum.godotengine.org/u/system)\
**Post date:** [July 10, 2021, 2:09am UTC](https://forum.godotengine.org/t/how-can-i-make-control-node-margins-adjust-to-the-window-resolution/11024/2 "2021-07-10T02:09:51Z")

</div>

| | | |
| --- | --- | --- |
| 👤 | **Reply From:** | Yuminous |

You need to make use of the anchor points — these four green pins:

![Anchor Points](https://i.imgur.com/iu8nZCi.png)  
UI elements all move relative to their location.  
If they are all together like this then your element will just translate:

![Default — Top-Right](https://i.imgur.com/MgKWBxW.jpg) ![Centered](https://i.imgur.com/BDi3Rjf.jpg)  
Instead, dragging them around the corners of your UI element like this will anchor the element to its original position and resize it relative to the screen like you are wanting:

![Anchor Points surrounding the UI element](https://i.imgur.com/GGRuksb.png)  
 ![Anchored to the Original Position](https://i.imgur.com/VAEo3Y7.jpg)

You can read a little bit more about UI anchoring here:

> **[Size and anchors](https://docs.godotengine.org/en/latest/tutorials/ui/size_and_anchors.html)**
>
> If a game was always going to be run on the same device and at the same resolution, positioning controls would be a simple matter of setting the position and size of each one of them. Unfortunately...

Hope that it helps! Good luck!

Okay, I was able to do it through a process inspired by this post. basically, I put the anchor in the top right and then I just wrote some code:

> margin\_right = get\_setting(“display/window/size/width”) - desired\_margin  
> margin\_bottom = get\_setting(“display/window/size/height”) - desired\_margin

desired margin is a variable with your desired margin. If it is changed all margins have to be set. I’m just putting this here in the hopes that somebody else finds it and also so that people know that I figured it out.

Cogan | 2021-07-30 23:40

---

<div class="post-metadata">

**Author:** ![system](https://forum.godotengine.org/uploads/default/original/2X/4/4b0a7fa8a6334634b94a13d421f0d99e6f04e21f.svg) [@system](https://forum.godotengine.org/u/system)\
**Post date:** [July 10, 2021, 11:42am UTC](https://forum.godotengine.org/t/how-can-i-make-control-node-margins-adjust-to-the-window-resolution/11024/3 "2021-07-10T11:42:17Z")

</div>

| | | |
| --- | --- | --- |
| 👤 | **Reply From:** | Snail0259 |

In addition to what yuminous said, you can also go into settings, and under `display -> window`, change `mode` to `2d` or `viewport`, and change `aspect` to `expand`.

This does work, but it doesn’t do quite what I need it to.

Cogan | 2021-07-15 20:51

What isn’t working for you? Beyond these solutions, it’s possible to change almost anything about control node sizing and the display of content (like text) through scripting.

Yuminous | 2021-07-17 02:37
