I have seen at least two different ways to answer your question.
Some define the slope of road/trail/etc. as the rise (vertical change) divided by the run (horizontal change). So, if you reduced the problem to that of a right triangle, the slope is the vertical leg divided by the horizontal leg.
Others define the slope as the vertical distance divided by the distance traveled or, if reduced to that of a right triangle, the vertical leg divided by the hypotenuse.