+ 3

Stacking up stuff

Is it possible to make the new div appears on top of the old ones? https://code.sololearn.com/WgoX6fDm66TO/?ref=app

28th Oct 2018, 2:51 AM
Fernando Moceces
Fernando Moceces - avatar
8 Réponses
+ 2
Maybe this is what you are looking to do. [edit] Hatsy Rei good lookin out ; ) I guess i missed that. Maybe this? https://code.sololearn.com/WW4EVeZuU3MO/?ref=app
29th Oct 2018, 3:40 AM
xpnvdo
xpnvdo - avatar
+ 5
Adding position:absolute; to the div style would make them all stack up. :>
28th Oct 2018, 2:58 AM
Hatsy Rei
Hatsy Rei - avatar
+ 4
xp nvdo That looks like the output of the first reply I provided. I think what OP wants is to have new divs appear there (which is what you have achieved), but old divs move downwards, giving way to the new div, e.g. A <- div A .... B <- new div B A <- div A now at bottom ... C <- new div C B <- old div B A <- oldest div A It is certainly achievable by storing and manipulating the position of each div within the container, but I need some time to sit down and get a code working.
29th Oct 2018, 3:50 AM
Hatsy Rei
Hatsy Rei - avatar
+ 3
xp nvdo Looking good indeed. ;>
29th Oct 2018, 5:27 AM
Hatsy Rei
Hatsy Rei - avatar
+ 3
Thank you xp nvdo ! So the magic word is .unshift() Nice to learn new cool stuff, yo :)
30th Oct 2018, 2:05 AM
Fernando Moceces
Fernando Moceces - avatar
+ 2
That's very cool, thank you, but not what I'm trying to accomplish. Imagine SoloLearn activity feed. When a new activity comes in, the old ones move downwards to make room for the new one. That's what I mean by stacking up. Is that even posible with the divs?
28th Oct 2018, 11:04 AM
Fernando Moceces
Fernando Moceces - avatar
+ 1
Thank you, but adding position:absolute; to the div style makes the new div covers the old ones.
28th Oct 2018, 3:56 AM
Fernando Moceces
Fernando Moceces - avatar
+ 1
Fernando Moceces I thought that was exactly what you meant by having divs on top of each other. If you want to show them a little but still stack them, specify increasing values of top/left. https://code.sololearn.com/WF5f8upaSHeF/?ref=app
28th Oct 2018, 4:56 AM
Hatsy Rei
Hatsy Rei - avatar