search

Home  >  Q&A  >  body text

Align and scale images

I need help with this code on my W3Schools website, I want to keep all elements in the center of the page. However, when I center, the feature's lens targets the old position of the image.

https://www.w3schools.com/howto/tryit.asp?filename=tryhow_js_image_zoom

I changed the code, but I can’t understand it

When the image is centered, the lens is outside the image. Like this was her previous position

Image center, incorrect lens position

solved!!!

To solve this situation, create a div class="main" that contains all elements. In the CSS code, we used the settings our friend Samar gave us. Thank you Samar.

Image solved!

P粉015402013P粉015402013308 days ago363

reply all(1)I'll reply

  • P粉237029457

    P粉2370294572024-03-23 09:17:01

    So, from what I understand, you want the image and zoom results to remain as is, but centered in the page?

    If so, you need to use flexbox in your css like this:

    .img-zoom-container {
      position: relative;
      flex-direction: column;
      display: flex;
      align-items: center;
    }

    reply
    0
  • Cancelreply