In the following expression, n and m belong to the number basis and x is the position:
$$ \langle n|m \rangle = \int_x n^*(x) m(x) dx = \int_x \langle n|x \rangle \langle x|m \rangle dx $$
I understand $\langle n|m \rangle$ as the inner product of $|n\rangle$ and $|m\rangle$. However $\langle n|x \rangle$ and $\langle m|g \rangle$ make no sense to me. The reason is that the dimensions of number basis is countable infinite or finite (imagine harmonic oscillator or spin system), however, the dimensions of position is uncountable infinite. How can you take an inner product between vectors from different basis?