亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何制作 div 沿某個方向寬度減小的動畫?

如何制作 div 沿某個方向寬度減小的動畫?

交互式愛情 2023-10-24 09:52:02
好吧,我正在嘗試用動畫來減少 div 的寬度。我已經成功做到了,但它從右到左減少。我希望它從左到右減少。請幫忙。    .box{height:0%;         width:830px;         border-bottom:20px solid #c00;      -webkit-animation: increase 3s;      -moz-animation:    increase 3s;      -o-animation:      increase 3s;      animation:         increase 3s;      animation-fill-mode: forwards;     }    @keyframes increase {    100% {       width: 1px;    }   }
查看完整描述

2 回答

?
犯罪嫌疑人X

TA貢獻2080條經驗 獲得超4個贊

您還可以使用 css 的 Right 和 Position 屬性。


div.b {

  height: 0%;

  border-bottom: 20px solid #c00;

  width: 830px;

  right: 30px;

  position: absolute;

  -webkit-animation: increase 3s;

  -moz-animation: increase 3s;

  -o-animation: increase 3s;

  animation: increase 3s;

  animation-fill-mode: forwards;

}


@keyframes increase {

  100% {

    width: 10px;

  }

<!DOCTYPE html>

<html>


<body>

  <div class="b"></div>



</body>


</html>


查看完整回答
反對 回復 2023-10-24
?
汪汪一只貓

TA貢獻1898條經驗 獲得超8個贊

只需添加float:right到.box班級即可


 

        .box_LtR{

             height:0%;

             width:830px;

             border-bottom:20px solid #c00;  

            -webkit-animation: increase 3s;

            -moz-animation:    increase 3s; 

             -o-animation:      increase 3s; 

             animation:         increase 3s; 

             animation-fill-mode: forwards; 

         }


          @keyframes increase { 

            100% {

               width: 1px;

            }

         }

       

         .box_RtL{

           height:0%;

           width:830px;

           float:right;

           border-bottom:20px solid #c00; 

          -webkit-animation: increase2 3s;

          -moz-animation:    increase2 3s; 

           -o-animation:      increase2 3s; 

           animation:         increase2 3s; 

           animation-fill-mode: forwards; 

          }


        @keyframes increase2 {  

          100% {

             width: 1px;

          }

        }


 



 

    <div class="box_LtR">



    </div>


    <div class="box_RtL">



    </div>


其他 !


    .box_LtR{

         height:0%;

         width:830px;

         border-bottom:20px solid #c00;  

        -webkit-animation: increase 3s;

        -moz-animation:    increase 3s; 

         -o-animation:      increase 3s; 

         animation:         increase 3s; 

         animation-fill-mode: forwards; 

     }


      @keyframes increase { 

        100% {

           width: 1px;

        }

     }

   

     .box_RtL{

       height:0%;

       width:1px;

       border-bottom:20px solid #c00; 

      -webkit-animation: increase2 3s;

      -moz-animation:    increase2 3s; 

       -o-animation:      increase2 3s; 

       animation:         increase2 3s; 

       animation-fill-mode: forwards; 

      }


    @keyframes increase2 {  

      100% {

         width: 830px;

      }

    }

<div class="box_LtR">



</div>


<div class="box_RtL">



</div>


查看完整回答
反對 回復 2023-10-24
  • 2 回答
  • 0 關注
  • 169 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號