This site's layout is a good example of how a combination of adherence to multiple patterns yields balanced proportions and an overall consistent structure. The logo, for example, is spaced approximately 14px at the top and bottom within its header segment though it's indented 18px from the edge of the question header, making the top and bottom spacing approximately 30% smaller than the left side - other elements within the header are spaced similarly. On the other hand, the spacing of the text within the question header is approximately 9px on the bottom, 13px on the top, and 24px on the left side. That sets the top spacing to be approximately 50% smaller than the left side, and the discrepancy in the bottom is relative to the alignment of the text to the bottom of the main header in addition to it being header text (separated from the main content with a divider, though closer to that content which it more closely relates to than anything else that surrounds it).
Proportions vary and are an art in themselves. There is a math to it all, but bringing a complex structure together is, in practice, a generally intuitive process.
I'm sure there are multiple books and online resources that touch on this, and they are all likely helpful in their own ways, but my best advice is to be an avid observer of proportions in the things around you - in themselves and relative to their environments and other things in that environment - especially in nature. In time you will hone your intuition and begin to more naturally imitate those proportions and apply them in their appropriate settings.