JSFiddle - React, Tailwind, and code Playground

by operatino

HTML

<div class="wrapper">
    <div class="static overflow-hidden">
        1 static
        <div class="absolute"></div>
    </div>
</div>

<div class="wrapper">
    <div class="static relative">
        2 relative
        <div class="absolute"></div>
    </div>
</div>

<div class="wrapper">
    <div class="static fixed">
        3 fixed
        <div class="absolute"></div>
    </div>
</div>

<div class="wrapper">
    <div class="static fixed">
        3 fixed
        <div class="absolute"></div>
    </div>
</div>

CSS

.wrapper {
    width: 100px;
    margin-bottom: 10px;
    position: relative;
}

.static {
    /* position: static - блоки по умолчанию статичны */
    overflow: hidden;
    width: 77px;
    height: 77px;
    margin: 20px;
    padding: 5px;
    background: red;
}

.absolute {
    position: absolute;
    right: -20px;
    top: 20px;
    width: 40px;
    height: 40px;
    background: green;
}

.relative {
    position: relative;
}

.fixed {
    position: fixed;
    left: 115px;
    top: 0;
}