The parent element of span is also span, and the position of the child element is lower than that of the parent element after using the child absolute parent phase. Why?

    <style>
        .a{
            font-size: 100px;
            position: relative;
        }
        .b{
            position: absolute;
            color: red;
            top: 0;
            left: 0;
        }
    </style>
    
    <span class="a"><span class="b"></span></span>
The

code is shown in the figure above. When the span element of .b is used as a child of span of .an and the child absolute parent phase is applied, there will be a problem with the following picture


.bspanline-height:100px


. Later, I added display:block/inline-block to the span style of the parent element to make the two elements completely overlap. Why? Is there any other solution?

Css
Mar.11,2021

just set inline-block for the parent element.
unless it is similar to span nesting a, other elements are generally not nested in inline elements, which contain differences between different browsers and the problem of inheriting parent element styles.

Menu