Using the adaptive time-dependent density matrix renormalization group method, we numerically study the spin dynamics and transport in one-dimensional spin-1/2 systems at zero temperature. Instead of computing transport coefficients from linear response theory, we study the real-time evolution of the magnetization starting from spatially inhomogeneous initial states. In particular, we are able to analyze systems far away from equilibrium with this set-up. By computing the timedependence of the variance of the magnetization, we can distinguish diffusive from ballistic regimes, depending on model parameters. For the example of the anisotropic spin-1/2 chain and at half filling, we find the expected ballistic behavior in the easy-plane phase, while in the massive regime the dynamics of the magnetization is diffusive. Our approach allows us to tune the deviation of the initial state from the ground state and the qualitative behavior of the dynamics turns out to be valid even for highly perturbed initial states in the case of easy-plane exchange anisotropies. We further cover two examples of nonintegrable models, the frustrated chain and the two-leg spin ladder, and we encounter diffusive transport in all massive phases. In the former system, our results indicate ballistic behavior in the critical phase. We propose that the study of the time-dependence of the spatial variance of particle densities could be instrumental in the characterization of the expansion of ultracold atoms in optical lattices as well.