html - Vertical align using transform: translateY(-50%); inside absolutely positioned div -


i'm trying vertically centre h2 inside div absolutely positioned height of 50% using following code:

#owl-demo h2 {     position: relative;     top: 50%;     -webkit-transform: translatey(-50%);     -ms-transform: translatey(-50%);     transform: translatey(-50%); } 

works fine on chrome, h2 disappears in safari ios unless set h2 positioned absolute , can't centre text text-align.

any appreciated, i've been trying make work day.

edit: looks height 50% problem on parent div, if remove text appears in ios. i'm trying achieve overlay covers 50% of thumbnail height there way cover 50% of thumbnail?

#owl-demo  .thumb-overlay {     text-align: center;     height: 50%; width: 100%; position: absolute; left: 0; bottom: 0; background:rgba(0, 0, 0, .8); z-index: 9999; opacity:0;     filter: alpha(opacity = 0);     -webkit-transition: 300ms ease-out;     -moz-transition: 300ms ease-out;     -o-transition: 300ms ease-out;     -ms-transition: 300ms ease-out;     transition: 300ms ease-out; }  #owl-demo  .thumb-overlay:hover {     opacity:0.75;     filter: alpha(opacity = 75);     transition:opacity 0.25s;     -moz-transition:opacity 0.25s;     -webkit-transition:opacity 0.25s; }  .touch #owl-demo  .thumb-overlay,  {     opacity:1;     filter: alpha(opacity = 1); }  #owl-demo h2 { font-size: .875em;     position: relative;     top: 50%;     -webkit-transform: translatey(-50%);     -ms-transform: translatey(-50%);     transform: translatey(-50%);     color: $white; } 

the following working me in safari (5.1.7)

#owl-demo h2 {  font-size: 1em;  -webkit-transform: translatey(100%);  -ms-transform: translatey(100%);  transform: translatey(100%);  color: white; } 

jsfiddle

as other ways, since can make use of ::before pseudo element aligning :

#owl-demo .thumb-overlay::before { content:""; display:block; height:30%; 

}

check jsfiddle


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -