In Tikz: how can I place a node A relative to the position of node B but with one coordinate fixed? Or put differently, how can one make two nodes share either the x or the y coordinate? For example, I would like to have box2 above box1 but not 0.3cm above box1, but let's say at y=3cm, here:
\documentclass[tikz, margin=1pt]{standalone}
\usetikzlibrary{3d}
\tikzset{box/.style={draw, rectangle}}
\begin{document}
\begin{tikzpicture}
\node (box1) [box] {};
\node (box2) [box, above of = box1, node distance = .3cm] {};
\end{tikzpicture}
\end{document}

\node (box2) [box] at (box1|-0,3) {};See https://tex.stackexchange.com/a/401429/121799 for more details on the|-and-|syntax. – Apr 24 '19 at 14:39(0,0), so @JouleV does work, too. Please notice that in your MWE you are using deprecated syntax. You will be much better off if you load\usetikzlibrary{positioning}and say something like\node (box2) [box, above=.3cm of box1] {};. (The3dlibrary is not used here.) – Apr 24 '19 at 15:04