Thanks to campa's comment (thanks!), I derived these many versions:
- above baseline
- aligned for math
- centered on baseline
- horizontal and centered on baseline

\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{cd}
\usetikzlibrary{backgrounds,positioning}
\usetikzlibrary{shapes,shapes.geometric,shapes.misc}
\usepackage{graphicx}
\begin{document}
\setlength{\fboxsep}{0pt}
\makeatletter
%% https://tex.stackexchange.com/questions/528774/excess-vertical-space-in-vdots/528775#528775
\DeclareRobustCommand\cvdotsAboveBaseline{%
\vbox{\baselineskip4\p@ \lineskiplimit\z@%
\hbox{.}\hbox{.}\hbox{.}}
}
\makeatother
\DeclareRobustCommand{\cvdotsCenterMathline}{%
% vcenter is used to center the argument on the 'math axis', which is at half the height of an 'x', or about the position of a minus sign.
\vcenter{\cvdotsAboveBaseline}%
}
\DeclareRobustCommand{\cvdotsCenterBaseline}{%
\raisebox{-.5\height}{%
$\cvdotsAboveBaseline$%
}%
}
\DeclareRobustCommand{\chdots}{%
\raisebox{-.5\height}{%
\rotatebox{90}{% Maybe better options than rotatebox...
$\cvdotsAboveBaseline$%
}%
}%
}
\DeclareRobustCommand{\chdotsLdots}{% Has a small space on the right and left, which chdots does not have
\raisebox{\dimexpr\depth-.5\totalheight\relax}{$\ldots$}%
}
\begin{tikzpicture}
\node[fill=red] (A) {A};
\node[fill=blue,below=of A] (B) {B};
\path (A) -- (B) node[midway,anchor=center] {\makebox[0pt][r]{$n$ }$\cvdotsCenterMathline$};
\end{tikzpicture}
% Show baseline then vdots:
Order: Original, above baseline, aligned for math, centered on baseline, horizontal and centered on baseline (2 versions):\
ABCp\rule{2cm}{0.1pt}\fbox{$\vdots$}\fbox{$\cvdotsAboveBaseline$}\fbox{$\cvdotsCenterMathline$}\fbox{$\cvdotsCenterBaseline$}\fbox{$\chdots$}\fbox{$\chdotsLdots$}
\end{document}
\raiseboxto cut off any depth or height you don't need. Like this:\raisebox{distance}[extend-above][extend-below]{text}http://www.emerson.emory.edu/services/latex/latex_148.html – gernot Oct 06 '21 at 13:38\hbox{.}is exactly how\vdotsid defined to begin with. – campa Oct 06 '21 at 13:55\vdotsin the Often referenced questions list, under "Math". But your answer is also good, so I've added it, to give another option. – barbara beeton Oct 06 '21 at 15:33