- Is it bad practice to use position absolute?
- Why we should not use position absolute in CSS?
- Is it bad to use position fixed?
- When should you use position absolute?
Is it bad practice to use position absolute?
There is nothing wrong with using position: absolute in the above example, but why not use an easier solution? Let's explore that. The first step is to add display: grid to the card component. We don't need to set any columns or rows.
Why we should not use position absolute in CSS?
Because position: absolute takes the element out of the flow of the document, everything else has to be adjusted to compensate for it, to make sure that elements don't overlap where you don't want them to. This tends to lead to increasingly complex CSS that breaks as soon as new content is added to a page.
Is it bad to use position fixed?
The concern with fixed positioning is that it can cause situations where the fixed element overlaps content such that is is inaccessible. The trick is having enough space to avoid that, and tricks like this.
When should you use position absolute?
When position absolute is used on an element, it is positioned absolutely with reference to the closest parent that has a position relative value. If there are no parent elements that has a relative position, then the absolutely positioned element will take its reference from the browser window.