Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #39145

Re: Animate element to position in grid

Newsgroups comp.lang.javascript
Subject Re: Animate element to position in grid
From "Evertjan." <exxjxw.hannivoort@inter.nl.net>
References <t6idneirmeYebS3CnZ2dnUU7-SPNnZ2d@westnet.com.au>
Date 2020-11-15 15:41 +0100
Message-ID <XnsAC769FAB5372Ceejj99@194.109.6.166> (permalink)

Show all headers | View raw


Andrew Poulos <ap_prog@hotmail.com> wrote on 15 Nov 2020 in 
comp.lang.javascript:

> I have a "small" div that appears at a random spot in the page. The page 
> is split by a responsive CSS grid into an number grid areas. I need to 
> move the div into the centre of one of the areas to a position that 
> would match "place-self: center".
> 
> Is there a way I get the offsetLeft and Top positions of the "finished" 
> location?
> 
> One idea was to clone the div, set its visibility to hidden, place it 
> with CSS, get its position, and then to remove it.

No need for cloning, you can just change the parent of your little element.

newParent.appendChild(littleElement);

For centering, see:

<https://css-tricks.com/centering-css-complete-guide/>

-- 
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Animate element to position in grid Andrew Poulos <ap_prog@hotmail.com> - 2020-11-15 20:10 +1100
  Re: Animate element to position in grid "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2020-11-15 15:41 +0100
    Re: Animate element to position in grid Andrew Poulos <ap_prog@hotmail.com> - 2020-11-16 08:15 +1100
  Re: Animate element to position in grid "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2020-11-15 11:05 -0800
    Re: Animate element to position in grid Andrew Poulos <ap_prog@hotmail.com> - 2020-11-16 08:27 +1100
      Re: Animate element to position in grid "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2020-11-15 16:51 -0800
        Re: Animate element to position in grid Andrew Poulos <ap_prog@hotmail.com> - 2020-11-16 13:34 +1100

csiph-web