Is there a way to modify the container class with css so that spinner looks inside the container (the container has the dynamic height to be more or equal the spinner height)?
.container {
border: 1px solid green;
}
.spinner {
display: flex;
position: absolute;
right: 30%;
border: 1px solid red;
}
.spinner::before {
content: "Why this text is not inside green";
font-size: 24px;
}
<div class="container">
<div class="spinner">
</div>
</div>
<div>
Why this text is not below another text?
</div>
5
Answers
is this what are you trying to achieve ?
i changed the positioning: .spinner is now correctly positioned relative to the .container.
and added container Flexibility: The .container can have dynamic height, and the spinner will stay centered.
Your
.container
should haveposition: relative
so the.spinner
will be relative to the.container
Here’s the description of answer given by – Roko C. Buljan in comments
just update your container class to:
The .spinner element is taken out of the normal document flow and positioned absolutely. This is done so that it will be placed at a specific location within its containing element.
To make the spinning circle appear inside the box, you need to change the appearance of both the box and the circle. This is done by changing the styling of both parts. You want the circle to be placed correctly within the box, which can change in size.
CSS Changes:
Container position should be relative: This would allow for the absolute positioning of the spinner to be set relative to this container.
Position the spinner: Add flexbox properties to center the spinner within the container.
Consider using a grid with the contents super-centered and not needing the absolute positioning. The grid then adjusts to the content size.