<body>
    <div class="outer">
        <p>
            fixed box는 뷰포트에 고정되어
            스크롤을 하더라도 그 위치에 그대로 있습니다.
        </p>
        <div class="fixed-box">fixed box</div>
    </div>
</body>
body {
    height: 5000px;
    margin: 0;
}
.outer {
    height: 100%;
    margin-left: 150px;
    background-color: gold;
    padding: 1em;
}
.fixed-box {
    position: fixed;  /* 뷰포트가 Containing Block이 됨 */
    top: 100px; /* 뷰포트 기준 아래로 100px 이동 */
    left: 25px; /* 뷰포트 기준 오른쪽으로 25px 이동 */
    width: 100px;
    height: 100px;
    background-color: red;
}
실제로 적용된 모습 확인하기
<body>
    <div class="fixed">요소의 크기가 콘텐츠의 크기에 맞춰 결정</div>
</body>
body {
    height: 5000px;
    margin: 0;
}
.fixed { /* width: auto;  height: auto; */
    position: fixed;
    top: 0;
    left: 0;
    color: #fff;
    background-color: rgba(204, 51, 255, 0.7);
    border: 3px solid #39004d;
}
실제로 적용된 모습 확인하기
<body>
    <div class="fixed">top, bottom, left, right 속성의 영향을 받을 때</div>
</body>
body {
    height: 5000px;
    margin: 0;
}
.fixed { /* width: auto;  height: auto; */
    position: fixed;
    top: 0;
    bottom: 100px;
    left: 0;
    right: 100px;
    color: #fff;
    background-color: rgba(204, 51, 255, 0.7);
    border: 3px solid #39004d;
}
실제로 적용된 모습 확인하기
<body>
    <div class="fixed">aspect-ratio이 설정된 경우</div>
</body>
body {
    height: 5000px;
    margin: 0;
}
.fixed { /* width: auto;  height: auto; */
    position: fixed;
    top: 0;
    left: 0;
    aspect-ratio: 2 / 1; /* 가로 2 세로 1의 비율 */
    color: #fff;
    background-color: rgba(204, 51, 255, 0.7);
    border: 3px solid #39004d;
}
실제로 적용된 모습 확인하기
<body>
    <div class="fixed">margin-left: auto;가 설정된 경우</div>
</body>
body {
    height: 5000px;
    margin: 0;
}
.fixed {
    position: fixed;
    left: 0;
    right: 100px;
    width: 100px;
    margin-left: auto;
    color: #fff;
    background-color: rgba(204, 51, 255, 0.7);
    border: 3px solid #39004d;
}
실제로 적용된 모습 확인하기