Pin element to center

When trying to pin an element (a picture in this case) the option to pin it to the center of the screen isn’t available. Is there a way to achieve this with code? A bit of an oversight to not have “pin to center” available since it’s very useful for a lot of things.

  1. You can change the offset via the editor (but it’ll be in pixels, so it won’t be in the center on all monitors).

  2. On editor X you can pin it to the center without code, by setting it to position:fixed, left:50vw; top: 50vh tranform:translate(-50%, -50%).

  3. On the regular editor you can crate a custom element and set it’s CSS as in #2. You can’t do it with Wix elements.

Oh thats a really good answer thanks a lot ill try and implement it then.

You’re welcome :slight_smile:
Good luck

1 Like

@jonatandor35 How would I add a picture to the custom element? I was reading the documentation and it says i can either use a server url or a velo file. Do the files stored on my wix site have urls to them? And are velo files just custom css or can i reference the image file i want inside the velo file and have it work that way?

@guilhermemartinsbara Yes. files you upload to your media manger do have a URL. Go to the media manager, hiver over the file, click the 3-dot menu, clikc Copy URL.
See also Velo Example: Coding a Basic Custom Element with Images

1 Like