css实现元素渐出(从左到右,从右到左等)

效果:
css实现元素渐出(从左到右,从右到左等)_第1张图片
实现很简单,是css的动画属性animation
以下是代码

/* 动画效果 */
      .enter-x-left {
        z-index: 9;
        opacity: 0;
        animation: enter-x-left 0.4s ease-in-out 0.3s;
        animation-fill-mode: forwards;
        transform: translateX(-50px);
      }
      .enter-x-right {
        z-index: 9;
        opacity: 0;
        animation: enter-x-right 0.4s ease-in-out 0.3s;
        animation-fill-mode: forwards;
        transform: translateX(50px);
      }
      .enter-x-left:nth-child(1),
      .enter-x-right:nth-child(1) {
        animation-delay: 0.1s;
      }
      .enter-x-left:nth-child(2),
      .enter-x-right:nth-child(2) {
        animation-delay: 0.2s;
      }
      .enter-x-left:nth-child(3),
      .enter-x-right:nth-child(3) {
        animation-delay: 0.3s;
      }
      .enter-x-left:nth-child(4),
      .enter-x-right:nth-child(4) {
        animation-delay: 0.4s;
      }
      

      @keyframes enter-x-left {
        to {
          opacity: 1;
          transform: translateX(0);
        }
      }
      @keyframes enter-x-right {
        to {
          opacity: 1;
          transform: translateY(0);
        }
      }
	<div>
	
        <p class="enter-x-left">css渐出从左到右p>
        <img src="./assets/bg_left.png" style="height: 350px" class="enter-x-left" alt="" />
     div>
      <div>
      
        <p class="enter-x-right">css渐出从右到左p>
        <div class="enter-x-right">
          <input type="text" />
        div>
        <div style="margin: 20px 0" class="enter-x-right">
          <input type="text" />
        div>
        <div class="enter-x-right">
          <input type="text" />
        div>
      div>

你可能感兴趣的:(css,动画,css3)