I guess you have seen sheaf cohomology as being the right derived functor of the global section functor, taking a sheaf $\mathcal{F}$ on a space $X$ to the abelian group $\Gamma(X,\mathcal{F})$. Suppose $X$ is a $k$-scheme, where $k$ is any field, with structural morphism $f:X\to\mathrm{Spec}(k)$. Then you can consider, on $\mathrm{Spec}(k)$, the sheaf $f_* \mathcal{F}$. Since sheaves on the spectrum of a field are not terribly sexy, you see that this guy is defined by its global sections, which by definition coincide with global sections of $\mathcal{F}$ over $X$: in other words, the functor $\Gamma(X,-)$ "coincides" with the functor $f_*$ (the reason for my quotes is that the first functor takes values in Ab while the second takes values in Sh($\mathrm{Spec}(k)$) but you can figure out the point, I guess).
Then, in general, given any map of schemes $f:X\to Y$ you can define for any sheaf $\mathcal{F}$ on $X$ its direct image $f_* \mathcal{F}$ getting a functor from Sh($X$) to Sh($Y$) who is left exact. Its right derived functors $R^if_*$ now produce sheaves on $Y$ and the $R^if_*\mathcal{F}$ can be thought of as the relative cohomology of $\mathcal{F}$, precisely as before. This is indeed done in Hartshorne, see Section 9 8 of chapter $III$ and self-references therein. You can also find something on this point of view in Weibel's Homological Algebra. Note that what I have said above does not need $f$ to really be a map between schemes, it works in a more general setting once you have a formalism taking "sheaves over somebody to sheaves over somebody else" – and this is the starting point of many cohomology theories you might encounter, like étale cohomology.
I guess you have seen sheaf cohomology as being the right derived functor of the global section functor, taking a sheaf $\mathcal{F}$ on a space $X$ to the abelian group $\Gamma(X,\mathcal{F})$. Suppose $X$ is a $k$-scheme, where $k$ is any field, with structural morphism $f:X\to\mathrm{Spec}(k)$. Then you can consider, on $\mathrm{Spec}(k)$, the sheaf $f_* \mathcal{F}$. Since sheaves on the spectrum of a field are not terribly sexy, you see that this guy is defined by its global sections, which by definition coincide with global sections of $\mathcal{F}$ over $X$: in other words, the functor $\Gamma(X,-)$ "coincides" with the functor $f_*$ (the reason for my quotes is that the first functor takes values in Ab while the second takes values in Sh($\mathrm{Spec}(k)$) but you can figure out the point, I guess).
Then, in general, given any map of schemes $f:X\to Y$ you can define for any sheaf $\mathcal{F}$ on $X$ its direct image $f_* \mathcal{F}$ getting a functor from Sh($X$) to Sh($Y$) who is left exact. Its right derived functors $R^if_*$ now produce sheaves on $Y$ and the $R^if_*\mathcal{F}$ can be thought of as the relative cohomology of $\mathcal{F}$, precisely as before. This is indeed done in Hartshorne, see Section 9 of chapter $III$ and self-references therein. You can also find something on this point of view in Weibel's Homological Algebra. Note that what I have said above does not need $f$ to really be a map between schemes, it works in a more general setting once you have a formalism taking "sheaves over somebody to sheaves over somebody else" – and this is the starting point of many cohomology theories you might encounter, like étale cohomology.