To make two HTML elements have the same center using CSS and Javascript, you can use the following steps:
offsetWidth
and offsetHeight
properties in javascript.transform: translate
property and pass in the difference between the center points.Here is an example implementation:
74 chars3 lines
index.tsx777 chars22 lines
This will position element1
and element2
such that they have the same center point.
gistlibby LogSnag