Skip to content

[CSS-align][CSSOM] New attribute for block level vertical centering the content #2017

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Nadya678 opened this issue Nov 29, 2017 · 4 comments

Comments

@Nadya678
Copy link

Nadya678 commented Nov 29, 2017

It is easy for me to define:

html
{
   display:table;
   width:100%;
   border:none;
   border-spacing: 0px;
   height:100%;
}
body
{
   display:table-cell;
   vertical-align:middle; 
   /* here add padding to make area for fixed-positioned elements like menu, nav-bar*/
}

but centering of content inside other elements is hard. There is no ideal solution.

Can you add style:
display: block-cell (and probably inline-block-cell)?
Display like block but with working: vertical-align:bottom and vertical-align:middle;

I know, I can use flexbox but... I must add additional container to do it and flexbox has additional adverse effects for elements inside it.

@Nadya678 Nadya678 changed the title New attribute for block level vertical centering the content [CSS-align] New attribute for block level vertical centering the content Nov 29, 2017
@Nadya678
Copy link
Author

Nadya678 commented Nov 29, 2017

BTW. If in the example is more text inside <body/> - which element should have defined scrollTop property? (overflow: scroll doesn't work for table elements - I suggest document or window but please test Cr, IE and FF).

  • <body/>
  • <html/>
  • document
  • window?

@Nadya678 Nadya678 changed the title [CSS-align] New attribute for block level vertical centering the content [CSS-align][CSSOM] New attribute for block level vertical centering the content Nov 29, 2017
@tabatkins
Copy link
Member

This is already defined in the spec you link to: align-content: center on a block will vertically center the content (once browsers implement the alignment properties on blocks).

@Nadya678
Copy link
Author

Thank you for explanation. This style will solve this problem if it will be implemented.
BUT what about CSSOM [scrollTop] for display:table on <html/> element described here? Shall I put new issue?

@tabatkins
Copy link
Member

Yeah, that sounds like a totally separate issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants