The height of the innermost element is defined as a percentage, and the height is determined by the outermost element.

    <style>
        .base {
            margin: 30px 0 0;
            min-height: 500px;
            position: relative;
            border: 1px solid black;
        }
        .outer {
            padding: 15px 0;
            width: 100%;
            box-sizing: border-box;
            border: 1px solid -sharp00bb54;
        }
        .parent {
            padding: 0 2%;
            height: 47px;
            display: block;
            border: 1px solid -sharpf75959;
        }
        .parent a {
            display: inline-block;
            position: absolute;
            right: 2%;
            height: 50%;
            border: 1px solid darkblue;
        }
    </style>
<div class="base">
    <div class="outer">
        <div class="parent">
            <a href="-sharp"></a>
        </div>
    </div>
</div>
The

code is shown above with the following result:

clipboard.png

Mar.25,2022

has this effect because the innermost element is set to absolute positioning, which is referenced by the ancestral element closest to him with relative or absolute positioning attributes, so here we will use base as a reference to set the height of element a

.
Menu