ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • div 색상 및 호버 애니메이션 애니메이션
    카테고리 없음 2020. 8. 18. 03:36

    질문

    div에서 만든 선이 있습니다. 이제 div 색상, 배경 회색에 애니메이션을 적용한 다음 흰색으로 채운 다음 흰색이 미끄러지 듯 회색으로 다시 채워집니다. 그런 다음 줄과 텍스트를 약 10px 위로 이동 한 다음 놓으면 기본 위치로 돌아갑니다.

    여기 하단에있는 이와 같은

    .scroll-indicator {
        position: absolute;
        left: 50%;
        bottom: 0;
        z-index: 340;
        display: inline-block;
        width: 4.16667%;
        height: 6.66667%;
        min-height: 60px;
        font-family: 'rajdhani', 'Helvetica Neue', Helvetica, sans-serif;
        font-weight: bold;
        font-style: normal;
        color: #000;
        font-size: 16px;
    }
    .scroll-indicator .border-grey {
        position: absolute;
        left: 0;
        top: 0;
        z-index: 100;
        width: 2px;
        height: 100%;
        background: #333;
    }
    .scroll-indicator .border {
        position: absolute;
        left: 0;
        top: 0;
        z-index: 200;
        width: 2px;
        height: 100%;
        background: #000;
    }
    .scroll-indicator em {
        display: inline-block;
        font-style: normal;
        -webkit-transform: rotate(-90deg);
        transform: rotate(-90deg);
        -webkit-transform-origin: center center;
        transform-origin: center center;
        position: absolute;
        left: 0px;
        top: 12px;
    }
    
    @media screen and (max-width: 800px) {
    .scroll-indicator {
        bottom: 0;
    }
    }
    <a href="" class="scroll-indicator" style="opacity: 1; transform: matrix(1, 0, 0, 1, 0, 0);">
    		<div class="border-grey"></div>
    		<div class="border" style="transform: matrix(1, 0, 0, 1, 0, 0); transform-origin: 0% 0% 0px;"></div>
    		<em>scroll</em>
    	</a>


    답변1

    CSS3 애니메이션 을 사용할 수 있습니다. 전환 해당 동작을 구현합니다.

    애니메이션을 구현하려면 일반적으로 코딩하기 전에 무슨 일이 일어나고 있는지 이해하는 것이 좋습니다. 이 경우 3 단계로 간단하게 설명 할 수 있습니다.

    1. 요소는 top : 0 에서 시작하고 height : 0 으로 시작합니다.

    이를 염두에두고 키 프레임 .

    다음은이를 수행하는 방법에 대한 작은 예입니다.

    body {
      background: #555;
    }
    
    .scroll-indicator {
    	position: absolute;
    	bottom: 0;
    	width: 30px;
    	left: 50%;
    	height: 60px;
    	transition: height .25s linear;
    	cursor: pointer;
    }
    
    .scroll-indicator:hover {
    	height: 75px;
    }
    
    .scroll-indicator .border-grey {
    	position: absolute;
    	top: 0;
    	bottom: 0;
    	left: 0;
    	width: 2px;
    	background: #333;
    }
    
    .scroll-indicator .border-white {
    	position: absolute;
    	top: 0;
    	left: 0;
    	width: 2px;
    	background: #fff;
    	animation-name: animation;
        animation-duration: 3s;
    	animation-iteration-count: infinite;
    }
    
    .scroll-indicator span {
    	transform: rotate(-90deg);
    	position: absolute;
    	top: 10px;
      color: #fff;
    }
    
    @keyframes animation {
    	0% {
    		height: 0;
    	}
    	33% {
    		top: 0;
    		height: 100%;
    	}
    	66% {
    		top: 100%;
    		height: 0;
    	}
    	100% {}
    }
    <div class="scroll-indicator">
    	<div class="border-grey"></div>
    	<div class="border-white"></div>
    	<span>scroll</span>
    </div>



     

     

     

     

    출처 : https://stackoverflow.com/questions/48349873/animate-div-color-plus-hover-animation

    댓글

Designed by Tistory.