FE/인터렉티브 웹

메인 부분에 움직이는 사진을 넣기

이제하네 2023. 11. 8. 09:34
* {
    margin: 0px;
    padding: 0px;
}

#main {
    width: 100%;
    height: 100vh;
    overflow: hidden;
    background-color: #b1e1e2;
    animation: sky linear 20s infinite;
}

#title {
    width: 1000px;
    position: absolute;
    top: 68%;
    left: 50%;
    transform: translate(-50%, 150%);
    font: 92px/1 "Poiret one";
    color: #fff;
    text-align: center;
    animation: day linear 20s infinite;
}

section{
    width: 1000px;
    height: 500px;
    position: absolute;
    top: 63%;
    left: 50%;
    transform: translate(-50%, -70%);
}

section .sky {
    position: absolute;
    width: 100%;
    height: 100%;
}

section .sky .sun {
    position: absolute;
    top: 0px;
    left: 50%;
    margin-left: -100px;
    transform-origin: center 500px;
    animation: sun linear 20s infinite;
}

section .sky .cloud1 {
    position: absolute;
    top: 0px;
    left: 10%;
    animation: flow linear 10s infinite;
}

section .sky .cloud2 {
    position: absolute;
    top: 50px;
    left: 0%;
    animation: flow linear 20s infinite;
}

section .town .circle {
    position: absolute;
    bottom: 104px;
    left: 50%;
    margin-left: -165px;
    opacity: 0.7;
    animation: rotation linear 20s infinite; 
}

section .town .night {
    position: absolute;
    bottom: 0px;
    left: 40px;
}

section .town .day {
    position: absolute;
    bottom: 0px;
    left: 40px;
    animation: day linear 20s infinite;
}

section .people {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0px;
    left: 0px;
    animation: day linear 20s infinite;
}

section .people .man {
    position: absolute;
    left: 0%;
    bottom: 0px;
    animation: flow linear 7s infinite;
}

section .people .family {
    position: absolute;
    left: 0%;
    bottom: 0px;
    animation: flow linear 20s infinite;
}

@keyframes rotation {
	0% {transform: rotate(0deg);}
	100% {transform: rotate(360deg);}
}
@keyframes sky {
	0% {background-color: #b08fcc;}
	25% {background-color: #b1e1e2;}
	50% {background-color: #fcd2e2;}
	75% {background-color: #636888;}
	100% {background-color: #b08fcc;}
}
@keyframes sun {
	0% {opacity:0; transform: rotate(-90deg);}
	25% {opacity:1; transform: rotate(-30deg);}
	50% {opacity:1; transform: rotate(30deg);}
	75% {opacity:0; transform: rotate(90deg);}
	100% {opacity:0; transform: rotate(-90deg);}
}
@keyframes day {
	0% {opacity: 0;}
	25% {opacity: 1;}
	50% {opacity: 1;}
	75% {opacity: 0;}
	100% {opacity: 0;}
}
@keyframes flow {
	0% { left: 0%; opacity: 0;}
	10% { opacity: 1; }
	80% { opacity: 1; }
	100% { left: 90%; opacity: 0;}
}

css 부분

    <div id="main">
        <h1 id="title">동물원으로 가자!!!</h1>
        <section>
                <article class="sky">
                    <img src="img/sun.png" class="sun" />
                    <img src="img/cloud1.png" class="cloud1" />
                    <img src="img/cloud2.png" class="cloud2" />
                </article>

                <article class="town">
                    <img src="img/circle.png" class="circle" />
                    <img src="img/town_night.png" class="night" />
                    <img src="img/town_day.png" class="day" />
                </article>

                <article class="people">
                    <img src="img/man.png" class="man" />
                    <img src="img/family.png" class="family" />
                </article>
        </section>
    </div>

보여줄 화면 부분