Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

Relative to the page, horizontal alignment in CSS is easy - a margin:0 auto gets you by much of the time, and a text-align:center for some other cases.

My question to the gurus is not how to vertically align, but why is it so much more difficult? Why isn't there margin:auto 0? I mean, from a programming perspective.

Theoretically, it seems like the same algorithms would apply to both types of centering.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
239 views
Welcome To Ask or Share your Answers For Others

1 Answer

Good question and I don't know, but I would suspect the root of the problem is going to lie in HTML and therefore it's rendering engines being originally intended for document semantics as opposed to layout/printing semantics. CSS is exceptionally good at describing paragraphs, headings, and all kinds of document concerns and really weak when it comes to the larger DTP layout tasks which everyone now wants their websites to be.

In a nutshell: I think the problem is that HTML is being tasked for things it was not intended for. Quel surprise.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share

548k questions

547k answers

4 comments

86.3k users

...