Css layout: margins and padding versus absolute positioning?

I would like some feedback on the use of indentation and margins for page layout as compared to absolute positioning. I understand that there are and will be scenarios where both or both are preferable, and this will depend on the scenario.

But what I get is a generic page layout for perfect pixel designs, what is the general rule? I’m a little over a year in HTML and CSS, and I proceed from graphic design, so most of my thought lies at the heart of the design approach in terms of layout in the first place. So far in my web projects, I have used the rule of thumb to use appropriately named divs with floats, indentation and margins when laying out the page, and if something requires absolute positioning (for example, an element is stuck at the edge of the screen or div) use it if necessary.

But lately, I am really starting to rethink my approach to page layout and wonder if the beginning with absolute positioning, as a general rule, is a better idea?

Can someone point out some good articles or resources on this topic, and I would also like to hear all the personal reviews.

+3
source share
3 answers

I can see where you are from, but using absolute positioning for your layout is extremely inflexible. I think it's best for you to continue as you are using the CSS window model. This does not mean that absolute positioning is bad, just because it is not flexible enough to handle liquid models, changing the size of boxes, etc.

+2
source

CSS 2 , float/margin, , , .

, , , ( ) . IE, , outlier, IE6/7. , , , , .

, , , !

0

Rowan, - .

, , , -, .

A: Symmetrical and attractive layout

B: Someone who knows this much better than any of us who dealt with all the problems that float and fields can cause and will update the structure in the future to compensate for the development of web development.

0
source

Source: https://habr.com/ru/post/1719725/


All Articles