CSS - Rotar con un punto fijo

 
Vista:
sin imagen de perfil
Val: 82
Ha mantenido su posición en CSS (en relación al último mes)
Gráfica de CSS

Rotar con un punto fijo

Publicado por Marta (32 intervenciones) el 07/03/2021 15:11:53
Buenas, tengo una imagen partida en dos. En un momento dado quiero hacer una rotación de la siguiente manera:
- la de la izquierda, rote hacia la izquierda, manteniendo fijo el punto inferior derecho
- la de la derecha, rote hacia la derecha, manteniendo fijo el punto inferior izquierdo.

Algo hago mal, pues la rotación la hace bien, pero no me mantiene los puntos fijos.
El código es este:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<div class="marc">
            <img class="dreta" src="imatges/noiaEsquerra.png">
            <img class="esquerra" src="imatges/noiaDreta.png">
        </div>
 
.marc {
    background: url(../imatges/bolet.jpg) no-repeat right;
    border: 10px solid #dfe0df;
    transform: rotate(10deg);
    position: fixed;
    right:8%;
    height:30%;
    top: 39%;
    float: left; /* per què s'ajuntin les imatges */
}
.dreta {
    height: 30vh;
    transform-origin: bottom left;
    animation-name: toLeft;
    animation-duration: 10s;
    animation-delay: 6s;
    float: left; /* per què s'ajuntin les imatges */
}
 
.esquerra {
    height: 30vh;
    transform-origin: bottom right;
    animation-name: toRight;
    animation-duration: 10s;
    animation-delay: 6s;
    float: left; /* per què s'ajuntin les imatges */
}
@keyframes toLeft {
    0%   {transform:rotate(-10deg)}
    100% {transform:rotate(-10deg)}
}
@keyframes toRight {
    0%   {transform:rotateY(10deg)}
    100% {transform:rotateY(10deg)}
}

Aquí las dos imágenes,
tancat
obert
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
Imágen de perfil de joel
Val: 870
Oro
Ha mantenido su posición en CSS (en relación al último mes)
Gráfica de CSS

Rotar con un punto fijo

Publicado por joel (252 intervenciones) el 08/03/2021 08:25:47
Hola Marta, segun entiendo, quieres que se separen las dos imagenes como si se partieran por la mitad, no?

Haber si te sirve esta prueba que he realizado:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<!doctype html>
<head>
</head>
<body>
    <div class="marc">
        <img class="esquerra" src="tancat.png">
        <img class="dreta" src="obert.png">
    </div>
</body>
 
<style>
.esquerra {
    height: 30vh;
    transform-origin: bottom right;
    animation-name: toLeft;
    animation-duration: 2s;
    animation-delay: 1s;
    float: left; /* per què s'ajuntin les imatges */
}
.dreta {
    height: 30vh;
    transform-origin: bottom left;
    animation-name: toRight;
    animation-duration: 2s;
    animation-delay: 1s;
    float: left; /* per què s'ajuntin les imatges */
}
@keyframes toLeft {
    0%   {transform:rotate(0deg)}
    100% {transform:rotate(-10deg)}
}
@keyframes toRight {
    0%   {transform:rotate(0deg)}
    100% {transform:rotate(10deg)}
}
</style>
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
1
Comentar
sin imagen de perfil
Val: 82
Ha mantenido su posición en CSS (en relación al último mes)
Gráfica de CSS

Rotar con un punto fijo

Publicado por Marta (32 intervenciones) el 09/03/2021 21:25:46
Joel, así es, ahora me funciona. Muchas gracias
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar