# How to center webcontainer?

**URL:** <https://forum.xojo.com/t/how-to-center-webcontainer/56485>\
**Category:** Web\
**Created:** [August 30, 2020, 4:35pm UTC](https://forum.xojo.com/t/how-to-center-webcontainer/56485 "2020-08-30T16:35:57Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![ronaldo\_florendo](https://forum.xojo.com/user_avatar/forum.xojo.com/ronaldo_florendo/32/159_2.png) [@ronaldo\_florendo](https://forum.xojo.com/u/ronaldo_florendo)\
**Post date:** [August 30, 2020, 4:35pm UTC](https://forum.xojo.com/t/how-to-center-webcontainer/56485/1 "2020-08-30T16:35:57Z")

</div>

From the old version of xojo, I usually do this code to center container control in web page.

```
dim c as New cc_login 

```

Dim h As Integer = ( Self.Height - c.Height ) /2  
Dim varLeft As Integer = (Self.Width - c.Width) /2  
c.EmbedWithin(Self, varLeft , h, c.width , c.Height)

With Web2.0, container control is position at the lower right part of the webpage.  
How to center webcontainer?

---

<div class="post-metadata">

**Author:** ![Jean-Yves\_Pochez](https://forum.xojo.com/user_avatar/forum.xojo.com/jean-yves_pochez/32/21769_2.png) [@Jean-Yves\_Pochez](https://forum.xojo.com/u/Jean-Yves_Pochez)\
**Post date:** [August 30, 2020, 5:12pm UTC](https://forum.xojo.com/t/how-to-center-webcontainer/56485/2 "2020-08-30T17:12:19Z")

</div>

drag it in the middle of the page until you see a blue crosshair behind it  
it is then centered without the need of any code.

---

<div class="post-metadata">

**Author:** ![ronaldo\_florendo](https://forum.xojo.com/user_avatar/forum.xojo.com/ronaldo_florendo/32/159_2.png) [@ronaldo\_florendo](https://forum.xojo.com/u/ronaldo_florendo)\
**Post date:** [August 30, 2020, 5:15pm UTC](https://forum.xojo.com/t/how-to-center-webcontainer/56485/3 "2020-08-30T17:15:30Z")

</div>

Thanks Jean,

But I need to do this with code because customer had different screen sizes, and I also use multiple webcontainer on a single page.

Any other idea?

---

<div class="post-metadata">

**Author:** ![Jean-Yves\_Pochez](https://forum.xojo.com/user_avatar/forum.xojo.com/jean-yves_pochez/32/21769_2.png) [@Jean-Yves\_Pochez](https://forum.xojo.com/u/Jean-Yves_Pochez)\
**Post date:** [August 30, 2020, 5:34pm UTC](https://forum.xojo.com/t/how-to-center-webcontainer/56485/4 "2020-08-30T17:34:15Z")

</div>

with the method I described, it is centered on any screen size.

---

<div class="post-metadata">

**Author:** ![ronaldo\_florendo](https://forum.xojo.com/user_avatar/forum.xojo.com/ronaldo_florendo/32/159_2.png) [@ronaldo\_florendo](https://forum.xojo.com/u/ronaldo_florendo)\
**Post date:** [August 30, 2020, 5:44pm UTC](https://forum.xojo.com/t/how-to-center-webcontainer/56485/5 "2020-08-30T17:44:54Z")

</div>

Yeah, it works!

Does this mean, there is no more way to make it dynamic just like I did it via code?

---

<div class="post-metadata">

**Author:** ![AlbertoD](https://forum.xojo.com/letter_avatar_proxy/v4/letter/a/dbc845/32.png) [@AlbertoD](https://forum.xojo.com/u/AlbertoD)\
**Post date:** [August 30, 2020, 6:25pm UTC](https://forum.xojo.com/t/how-to-center-webcontainer/56485/6 "2020-08-30T18:25:08Z")

</div>

Can you post a sample project? I can’t reproduce the problem so I may be missing something.

---

<div class="post-metadata">

**Author:** ![Ricardo\_Cruz\_Fernandez](https://forum.xojo.com/user_avatar/forum.xojo.com/ricardo_cruz_fernandez/32/328_2.png) [@Ricardo\_Cruz\_Fernandez](https://forum.xojo.com/u/Ricardo_Cruz_Fernandez)\
**Post date:** [August 30, 2020, 8:26pm UTC](https://forum.xojo.com/t/how-to-center-webcontainer/56485/7 "2020-08-30T20:26:20Z")

</div>

I think you’re having the same issue I’m having with Xojo using percentages, instead of pixels:  
\<[https://xojo.com/issue/61543](https://xojo.com/issue/61543)\>

You can achieve it like this:

```auto
c.LockTop = True
c.LockLeft = True

```

Then embed it.

---

<div class="post-metadata">

**Author:** ![ronaldo\_florendo](https://forum.xojo.com/user_avatar/forum.xojo.com/ronaldo_florendo/32/159_2.png) [@ronaldo\_florendo](https://forum.xojo.com/u/ronaldo_florendo)\
**Post date:** [August 31, 2020, 2:00am UTC](https://forum.xojo.com/t/how-to-center-webcontainer/56485/8 "2020-08-31T02:00:48Z")

</div>

Hi Ricardo,

Your suggestion works!!! Thank you!

```
 c.LockTop = True
c.LockLeft = True
```

---

<div class="post-metadata">

**Author:** ![system](https://forum.xojo.com/uploads/default/original/1X/455b4dcc0e61630e9f81940004ddffa49c432a46.png) [@system](https://forum.xojo.com/u/system)\
**Post date:** [April 29, 2021, 4:38pm UTC](https://forum.xojo.com/t/how-to-center-webcontainer/56485/9 "2021-04-29T16:38:37Z")

</div>


