# Positioning items in a container

**URL:** <https://forum.babylonjs.com/t/positioning-items-in-a-container/6990>\
**Category:** Questions\
**Tags:** tutorial, gui\
**Created:** [November 14, 2019, 1:59pm UTC](https://forum.babylonjs.com/t/positioning-items-in-a-container/6990 "2019-11-14T13:59:35Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![MartynovOleg](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/martynovoleg/32/4466_2.png) [@MartynovOleg](https://forum.babylonjs.com/u/MartynovOleg)\
**Post date:** [November 14, 2019, 1:59pm UTC](https://forum.babylonjs.com/t/positioning-items-in-a-container/6990/1 "2019-11-14T13:59:35Z")

</div>

Hello guys again) There is such a problem when you start to change the viewing area (when it becomes too large or small), the positioning of the golden background on the button moves out, although everything is set as a percentage. It is possible to somehow fix the position of the element inside the container or as -  
is there another way to fix this problem? I will be especially grateful if someone tells me how to position the element inside the container in the center. pivot in babylon, as I understand it, is only for meshes. What about container positioning? Do they have an anchor point? Thanks for any help  
[https://playground.babylonjs.com/#V4KWNU#1](https://playground.babylonjs.com/#V4KWNU#1)

---

<div class="post-metadata">

**Author:** ![Cedric](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/cedric/32/2742_2.png) [@Cedric](https://forum.babylonjs.com/u/Cedric)\
**Post date:** [November 14, 2019, 2:48pm UTC](https://forum.babylonjs.com/t/positioning-items-in-a-container/6990/2 "2019-11-14T14:48:17Z")

</div>

Hi @MartynovOleg

I’m not sure to understand. You want to lock the background to the top left of the button container?

---

<div class="post-metadata">

**Author:** ![MartynovOleg](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/martynovoleg/32/4466_2.png) [@MartynovOleg](https://forum.babylonjs.com/u/MartynovOleg)\
**Post date:** [November 14, 2019, 2:54pm UTC](https://forum.babylonjs.com/t/positioning-items-in-a-container/6990/3 "2019-11-14T14:54:51Z")

</div>

Suppose I centered the golden background relative to the background (pictures), all this by adjusting the values ​​of top and left in percent.  
In a certain size of the window in which I configured, everything is ok. But when you resize the window, the positioning of the button’s child (golden background) begins to shift,  
that is, it is not centered already. Is there any way to avoid this? And is it possible to somehow do without adjusting the position of the child element in the center “by eye”? If you do not understand, I can rephrase, or ask any additional questions.  
And yet, all this is translated through Google translator, so please excuse me)

---

<div class="post-metadata">

**Author:** ![Cedric](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/cedric/32/2742_2.png) [@Cedric](https://forum.babylonjs.com/u/Cedric)\
**Post date:** [November 14, 2019, 3:04pm UTC](https://forum.babylonjs.com/t/positioning-items-in-a-container/6990/4 "2019-11-14T15:04:33Z")

</div>

Maybe you can tweak using pixel values instead of %:

[https://playground.babylonjs.com/#V4KWNU#2](https://playground.babylonjs.com/#V4KWNU#2)

---

<div class="post-metadata">

**Author:** ![MartynovOleg](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/martynovoleg/32/4466_2.png) [@MartynovOleg](https://forum.babylonjs.com/u/MartynovOleg)\
**Post date:** [November 14, 2019, 3:11pm UTC](https://forum.babylonjs.com/t/positioning-items-in-a-container/6990/5 "2019-11-14T15:11:12Z")

</div>

So it was originally, but I don’t know how correctly it will be displayed on different resolutions and mobile devices, the goal is to avoid pixelation (poor image quality) and fix the locations of gui elements, because now elements at different resolutions are displayed in different places)) on friend etc.  
`Or use percentages to arrange elements on the "main screen", and use pixels to arrange elements inside containers. Although, in theory, AdvancedDynamicTexture (what I mean by the main screen) where all the controls are located is the same container`  
I took the idea of ​​switching from pixels to percent from here:

> [@Not sure how to support different screen resolutions with GUI](https://forum.babylonjs.com/t/not-sure-how-to-support-different-screen-resolutions-with-gui/965/3):
>
> Hi guys. [perhaps some info here.](https://forum.babylonjs.com/t/help-recover-my-gui-after-canvas-resize-plus-more/602) I was working with a diagram that needed to survive canvas resize, and sebavan helped me out… with some resize observers. I think… you can simulate different resolutions… by drag-resizing your browser window. For testing, I opened my f12 dev-tools and dragged its horizontal divider… up/down. And I dragged the divider between playground editor and canvas… as another test. This allows for full-power in-playground resolution-testing, I think. Also, you might …

---

<div class="post-metadata">

**Author:** ![MartynovOleg](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/martynovoleg/32/4466_2.png) [@MartynovOleg](https://forum.babylonjs.com/u/MartynovOleg)\
**Post date:** [November 14, 2019, 3:17pm UTC](https://forum.babylonjs.com/t/positioning-items-in-a-container/6990/6 "2019-11-14T15:17:44Z")

</div>

But still, thanks) If I do not find another option, I will use this one)
