In this MWE, is there anyway to automatically set the spacing between the second parent children instead of this manual approach
first/.style={level distance=6ex},
second/.style={level distance=12ex},
third/.style={level distance=18ex},
?
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,positioning,calc,trees}
\begin{document}
\pagestyle{empty}
\def\gap{10mm}
\begin{tikzpicture}[
node distance = 18mm and \textwidth/3,
on grid,
font = \sffamily,
line/.style = {draw, -Latex,black},
rbox/.style = {draw=blue!80!black, fill=blue!20,
rounded corners, inner sep=2mm,
text width=(\textwidth-6*\gap)/3, align=center},
grandchild/.style={grow=down,xshift=+2em,anchor=west,edge from parent path={ [line] ([xshift=0,yshift=0em]\tikzparentnode.south) |- (\tikzchildnode.west)}},
first/.style={level distance=6ex},
second/.style={level distance=12ex},
third/.style={level distance=18ex},
]
\node (Grandparent) [rbox] {Grandparent};
\node (1stparent) [rbox,below left=of Grandparent] {1st parent};
\node (2ndparent) [rbox,below=of Grandparent]{2nd parent}
child[grandchild,first] {node[rbox]{1st child}}
child[grandchild,second] {node[rbox]{2nd child}}
child[grandchild,third] {node[rbox]{3rd child}};
\node (3rdparent) [rbox,below right=of Grandparent] {3rd parent};
\path [line] (Grandparent) -- coordinate (a) (2ndparent);
\path [line] (a) -| (1stparent);
\path [line] (a) -| (3rdparent);
\end{tikzpicture}
\end{document}
Edit
Following cfr answer forest approach, how can I edit this code to make the children at level 3 (e.g. He-Ne, I, CO2, etc) be folder-like?
\documentclass[border=10pt,multi,tikz]{standalone}
\usepackage[edges]{forest}
\usetikzlibrary{arrows.meta,shadows.blur}
\begin{document}
\newlength\gap
\setlength\gap{10mm}
\begin{forest}
forked edges,
for tree={
draw=blue!80!darkgray,
fill=blue!80!darkgray!25,
rounded corners,
text width=(\textwidth-6*\gap)/3,
edge={-Latex},
font=\sffamily,
text centered,
blur shadow,
},
% where level=0{%
parent anchor=children,
% }{%
if level=2{%
folder,
grow'=0,
l sep+=10pt,
before typesetting nodes={child anchor=north},
edge path'={%
(!u.parent anchor) -- ++(0,-10pt) -| (.child anchor)
},
}{},
% }
[Active Media
[Gases
[Atoms
[He-Ne]
[I]
]
[Molecules
[CO2]
[CO]
]
[Ions
[Ar]
[Kr]
]
[Excimers
[ArF]
]
]
[Liquids
[Dyes
[Rhodamines]
]
]
[Solids
[Insulators
[Nd:YAG]
]
[Semiconductors
[GaAs]
]
]
]
\end{forest}
\end{document}



