Can text be centred vertically within a text box?

1,017 views
Skip to first unread message

Joshua Liebmann

unread,
Nov 21, 2017, 5:59:31 AM11/21/17
to Google Web Designer beta
Hi,

Wondering if it is possible to vertically centre text within a text box. 

Normally I can just manually position the text however when i'm using dynamic text that varies in length, obviously this isn't possible.

Thanks in advance!

Josh.


Kent Myers

unread,
Nov 21, 2017, 10:36:41 AM11/21/17
to Google Web Designer beta
Yes, this is possible. I have a blog post and demo video of this which may be available soon but in the meantime you can see this in most of the dynamic templates (cta-txt) and involves these steps:
  1. Wrap your text element in a container div of fixed dimensions
  2. Code view: add class "v-center" to your text element
  3. CSS panel on text element: remove "top" rule and change height to "max-height: 100%;"
  4. Add this style if needed (will be included in all Dynamic templates)
.v-center {
  position: relative;
  top: 49%;
  transform: translateY(-50%);
}


Hope that helps,

Kent
Google Web Designer team
Reply all
Reply to author
Forward
0 new messages