JSFiddle - React, Tailwind, and code Playground
HTML
<img src="http://placehold.it/40x40">
<div class="loading-spinner-overlay-1">
<div class="loading-spinner-background">
<div class="loading-spinner-container">
<img src="http://placehold.it/40x40">
</div>
</div>
</div>
<div class="loading-spinner-overlay-2">
<div class="loading-spinner-background">
<div class="loading-spinner-container">
<img src="http://placehold.it/40x40">
<p>
Some very long long long text
</p>
</div>
</div>
</div>
CSS
html {
box-sizing: border-box;
}
*, *:before, *:after {
box-sizing: inherit;
}
.loading-spinner-overlay-1 {
background-color: aliceblue;
left: 0;
top: 60px;
right: calc(100% - 300px);
bottom: calc(100% - 300px);
position: absolute;
z-index: 9999;
display: flex;
align-items: center;
justify-content: center;
}
.loading-spinner-overlay-2 {
background-color: aliceblue;
left: 0;
top: 300px;
right: calc(100% - 300px);
bottom: calc(100% - 600px);
position: absolute;
z-index: 9999;
display: flex;
align-items: center;
justify-content: center;
}
.loading-spinner-background {
min-width: 100px;
max-width: 50%;
background-color: white;
border-radius: 10px;
display: flex;
/* flex-direction: column; removed */
z-index: 1;
padding: 20px;
}
.loading-spinner-container {
min-height: 60px; /* added/value changed (moved from *-background class) */
display: flex;
flex-direction: column;
flex-grow: 1;
align-items: center; /* added (changed) */
justify-content: center; /* added */
width: 100%;
}
.loading-spinner-container > img {
/* margin: auto; removed */
}
.loading-spinner-container > p {
text-align: center;
margin: 0;
width: 100%;
}