The idea is good but it is a little more complicated.
You have to work with the tensor form of the electromagnetic field $ F^{\mu \nu}$and the 4 dimensions of space-time.
The Lorentz transformation that takes an electron from rest to an electron with a constant velocity can be seen as a rotation in the 4 dimensions of space time (${\Lambda^{\nu'}}_\nu $).
All tensors will change, "rotate", according to this rotation. Like 3 dimensional vectors rotate when you rotate a frame. Because the electromagnetic tensor has two indices you have to apply the rotation on each index as described here . And
Basically the tensor transforms like this:
$F^{\mu'\nu'} = {\Lambda^{\mu'}}_\mu F^{\mu\nu} {\Lambda^{\nu'}}_\nu $
And you get the new electric and magnetic field inside thisthe new tensor $F^{\mu'\nu'}$.
You
You could also use the electromagnetic potential vector $A^{\mu}$. Its transformation is simpler because it has only one index (it's a vector).
So basically your idea is good. Contraction (which is a rotation in fact) of space and time will "rotate" the electric and magnetic fields. The math involves tensor transformation.