I'm aware of the position:relative
and position:absolute
trick to position a div relative to its parent. But what if the div is not its parent and I want to position it relative to that? I'm trying to implement something along those lines.
I'm also aware of position:fixed
to fix a div but I'm building a responsive website and I'd like to avoid that. I found a question here which mentions using jQuery to do it: How to position one element relative to another with jQuery? Is jQuery the only way to do it? Can it be done using CSS as well?
I've put up a fiddle here: http://jsfiddle.net/19bdpgsf/. In the fiddle, I'm trying to position the child2
element relative to the notparentdiv
just like it has been positioned relative to the parent
div. Is it possible using only css?
Thanks.
position
, perharps display: flex could be worth to consider. – Tribe