Search code examples
htmlcssresponsive-designposition

Should I prevent from using position relative and absolute?


I have a friend that deals with web a pretty much time, and he is saying that the standard is almost not using absolute/relative position, especially when you doing responsive design.

I am totally beginner, and until now I use for positioning position:absolute or relative. is he right? How do you build a website usually?

Thank for response.


Solution

  • Positioning in CSS is a long and interesting chapter, and I would recomment reading through it all to get the basic understanding. There are lot of good resources available out there if you try to search for it.

    To try to answer your question, there is nothing wrong with using relative positioning - quite the contrary. All positioning is relative to something, and the most common way to control it is by using the position: relative; rule to the surrounding element you want your positioning to be relative to.

    So if you need to place something by using position: absolute; you want to make sure your positioning rules (for example offset from the top, bottom or sides) are measuring from where you want them to.

    It's also about the document flow, and positioning elements either way other than their defaults can make things tricky for you. Good luck.