Align and scale images
P粉015402013
P粉015402013 2024-03-22 11:26:07
0
1
337

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粉015402013
P粉015402013

reply all(1)
P粉237029457

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;
}
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template