The refractive index \( \mu \) is defined as the ratio of the real depth to the apparent depth:
\[
\mu = \frac{\text{Real Depth}}{\text{Apparent Depth}}.
\]
Let the real depth of the bubble be \( x \, \text{cm} \). The apparent depth when viewed from one side is \( 12 \, \text{cm} \), and when viewed from the opposite side, it is \( 24 - x \, \text{cm} \).
Using the refractive index formula, we have two expressions for \( \mu \):
\[
\mu = \frac{x}{12} \quad \text{(from one side)},
\]
\[
\mu = \frac{24 - x}{4} \quad \text{(from the opposite side)}.
\]
Equating these two expressions:
\[
\frac{x}{12} = \frac{24 - x}{4}.
\]
Simplifying the equation:
\[
4x = 12(24 - x).
\]
\[
4x = 288 - 12x.
\]
\[
16x = 288,
\]
which yields \( x = 18 \, \text{cm} \).
Substituting \( x = 18 \, \text{cm} \) into the first expression for \( \mu \):
\[
\mu = \frac{18}{12} = \frac{3}{2}.
\]
\[
\boxed{\frac{3}{2}}
\]