您可以在.parent中使用calc()以及.child中的position:absolute,通過閱讀您的注釋,它不會有第二個父級有問題的内容.
.container {
border: 1px solid green;
position: relative;
min-height: 200px;
}
.parent {
max-width: calc(100% - 220px)
}
.child {
position: absolute;
top: 0;
right: 0;
}
Hello world! I don't want to overlap with the image. Hello world! I don't want to overlap with the image. Hello world! I don't want to overlap with the image.
Hello world! I don't want to overlap with the image. Hello world! I don't want to overlap with the image. Hello world! I don't want to overlap with the image.
Hello world! I don't want to overlap with the image. Hello world! I don't want to overlap with the image. Hello world! I don't want to overlap with the image.