Notice
«   2024/11   »
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
관리 메뉴

Jade_o.o

[css] animation 실습2 - 문장 움직이기 본문

CSS

[css] animation 실습2 - 문장 움직이기

by jade 2024. 1. 13. 13:39

p태그에 담긴 문장이 오른쪽에서 왼쪽으로 움직이는 animation 효과를 구현해보자!

 

<!DOCTYPE html>
<html lang="ko">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="css_test21.css">
</head>
<body>
    <p>
        "As I relax on the sofa and gaze around a room a thought hits me: this is exactly the place I've been looking for all my life. A little hideaway in some sinkhole somewhere. I'd always thought of it as a secret, imaginary place, and can barely believe that it actually exists. I close my eyes and take a breath, and wonder of it all settles over me like a gentle cloud."
    </p>
</body>
</html>

html 코드

 

p {
    position: fixed;
    animation: sentence-slide 3s steps(100, end);
}

@keyframes sentence-slide {
    from {
        left: 100%;
        width: 100%;
    }
    to {
        left: 0%;
        width: 100%;
    }
}

css 코드