Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS transform: translate not working on iPad

Tags:

html

css

ipad

I've made a simple under construction website which has an image and some text centred in the middle of the page like following:

HTML Code:

<body>
    <div id="container">
        <span id="wip">Under Construction</span>
        <img id="image" src="katte.jpg">
        <span id="text">Glæd dig, her åbner katteboxen.dk i foråret 2015. Vi glæder os til at forkæle din kat med en spændende pakke hver måned.</span>
    </div>
</body>

CSS Code:

body {
    margin: 0;
    font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
    font-weight: 700;
    text-align: center;
}
#container {
    max-width: 1230px;
    width: 100%;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}
#image {
    width: 100%;
}
#text {
    font-size: 20px;
    padding: 0 15px;
    display: block;
}
#wip {
    font-size: 40px;
    padding: 0 15px;
    display: block;
}

Link: http://katteboxen.dk/

Everything is working good except when it comes to iPads. The content is showing like when for example the css rule transform: translate(-50%, -50%); wasn't applied for the container. What are the alternatives for fixing this issue? Any guidance or feedback is more than welcomed.

like image 263
MariusNV Avatar asked Oct 01 '14 07:10

MariusNV


People also ask

Does transform work on Safari?

It works great on Firefox, Internet Explorer and Chrome, however not in Safari.

How do you translate in CSS?

The CSS translate() function is used to move elements in a two-dimensional space. It moves the position of the element on the plane by the amount provided by tx and ty . The translate() function accepts two arguments, indicating how much to move the element along the x and y axes respectively.

What is translate y in CSS?

The translateY() CSS function repositions an element vertically on the 2D plane. Its result is a <transform-function> data type.

What is translate function in CSS?

The translate() CSS function repositions an element in the horizontal and/or vertical directions. Its result is a <transform-function> data type.


2 Answers

You might need to try browser specific prefixes for transform property, so:

-webkit-transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);

should do the trick.

For reference have a look here

like image 93
robjez Avatar answered Sep 23 '22 01:09

robjez


transform property are browser based property set -webkit-transform, -moz-transform, -o-transform .... ans so set it according to your i-pad browser i this it will solve the problem

or just use

margin-left:-50%;

margin-top:-50%;
like image 37
himanshu Avatar answered Sep 23 '22 01:09

himanshu