+ 1

Z index

Got two elements I’m trying to stack on each other ones a header the others and image . I concocted some code but who knows how messed it truly is lol cause I don’t . Any saviors out there help a noob out please

30th Mar 2018, 12:03 AM
Jeffrey Ramirez
Jeffrey Ramirez - avatar
38 Answers
+ 4
「HAPPY TO HELP」 , thank you 😍😍 😊😄, just following your leads yes I will 👍🙋
30th Mar 2018, 4:34 AM
Morpheus
Morpheus - avatar
+ 4
@Morpheus is there a way in CSS to get the Z index of the parent and increase it by one?
30th Mar 2018, 4:52 AM
Michael Simnitt
Michael Simnitt - avatar
+ 3
Dam, Ima try this tomorrow looking forward to it thank you guys will touch back with you then !
30th Mar 2018, 1:42 AM
Jeffrey Ramirez
Jeffrey Ramirez - avatar
+ 3
30th Mar 2018, 4:37 AM
「HAPPY TO HELP」
「HAPPY TO HELP」 - avatar
+ 3
not for keyframes I'm actually looking for more so for the purposes of a dynamic modal Handler. and just sorting out what I can do and CSS and what needs to be done in JavaScript. I know you can use the calc function in the CSS but I don't know much about it and whether or not I would be able to use it to pull the Z index and add one to value of the parent
30th Mar 2018, 5:06 AM
Michael Simnitt
Michael Simnitt - avatar
+ 3
I guess not Michael, but check it out though, calc() is meant to simplify length width issues in different units, but it won't be able to read zIndex, I think transitions and animations are the only CSS ways but I ll look into it more
30th Mar 2018, 5:13 AM
Morpheus
Morpheus - avatar
+ 3
thank you for the help Bud. I guess It will just be something I'll have to handle on the JavaScript end. it just would have been really nice to be able to build all the objects up front and as you move the parent just have the children dynamically update through CSS. not a big deal to add a function for it either though I guess.
30th Mar 2018, 5:14 AM
Michael Simnitt
Michael Simnitt - avatar
+ 3
Michael Simnitt , yes we should strive for CSS only solutions first it's best in many ways, is that modal code started? we ll take our discussions there
30th Mar 2018, 5:19 AM
Morpheus
Morpheus - avatar
+ 3
just a simple prototype that's kind of old in my codes. was hoping to learn from your example and make a library out of it that's got a little bit more Rich features
30th Mar 2018, 5:21 AM
Michael Simnitt
Michael Simnitt - avatar
+ 3
Michael Simnitt , I ll be glad to participate 🙋, sounds awesome
30th Mar 2018, 5:23 AM
Morpheus
Morpheus - avatar
+ 3
It'll be better if you post the code on the playground so you can see if thats the effect you wanted
5th Apr 2018, 9:07 PM
「HAPPY TO HELP」
「HAPPY TO HELP」 - avatar
+ 3
no youre just learning, dont feel sorry! its not annoying :)
5th Apr 2018, 11:33 PM
「HAPPY TO HELP」
「HAPPY TO HELP」 - avatar
+ 2
Well one thing people usually leave out is that the position has to be absolute in order to use z indexing CSS position: absolute; z-index: -1; /* This changes of course */ If you post code it will be easier to help and fix!
30th Mar 2018, 12:24 AM
「HAPPY TO HELP」
「HAPPY TO HELP」 - avatar
+ 2
4 things for overlaying 1. position of element on top must be absolute. 2. position of it s parent element must not be static , or left, right , top, bottom won't work for the child 3. use a z-index greater than the parent, by default z-index is 0 , so any big integer value will do, -ve value will hide it behind the background 4. use top, right, left, bottom on the overlay element to align it as u like it, and always position it using any 2 adjacent like top & right, top & left , bottom & right or bottom & left
30th Mar 2018, 12:31 AM
Morpheus
Morpheus - avatar
+ 2
it's a good doubt, here's a template to remember it parent Element { position: relative; } child Element { position : absolute; z-index : 5; top : 20px; right: 30px; }
30th Mar 2018, 12:34 AM
Morpheus
Morpheus - avatar
+ 2
@Michael, ok would keyframes won't work with zIndex?
30th Mar 2018, 5:04 AM
Morpheus
Morpheus - avatar
+ 2
Yea i dont mind haha post it here and we'll all get a notification
5th Apr 2018, 8:53 PM
「HAPPY TO HELP」
「HAPPY TO HELP」 - avatar
+ 2
well youre missing a </head> inside your head have a style tag <style> </style> make your p have an id, say id="top" and the bottom have an id="bottom" inside the style tag #top{ position: absolute ; z-index:1; } #bottom{ position: absolute; z-index:0; }
5th Apr 2018, 9:01 PM
「HAPPY TO HELP」
「HAPPY TO HELP」 - avatar
+ 2
the .p is wrong because . is if you have a class attribute
5th Apr 2018, 9:02 PM
「HAPPY TO HELP」
「HAPPY TO HELP」 - avatar
+ 2
just be p and img on css
5th Apr 2018, 9:02 PM
「HAPPY TO HELP」
「HAPPY TO HELP」 - avatar