freeCodeCamp/curriculum/challenges/arabic/01-responsive-web-design/applied-visual-design/create-movement-using-css-a...

3.7 KiB

id title challengeType videoUrl localeTitle
587d78a7367417b2b2512ae1 Create Movement Using CSS Animation 0 إنشاء حركة باستخدام CSS الرسوم المتحركة

Description

عندما يكون للعنصر position محدد ، مثل fixed أو relative ، يمكن استخدام خصائص إزاحة CSS إلى right left top bottom في قواعد الرسوم المتحركة لإنشاء حركة. كما هو موضح في المثال أدناه ، يمكنك دفع العنصر إلى الأسفل ثم إلى الأعلى عن طريق تعيين الخاصية top للإطار الرئيسي 50% إلى 50 بكسل ، ولكن بعد تعيينه على 0px للأول ( 0% 100% ) والإطار الرئيسي الأخير ( 100% ).
keyframes rainbow {

لون الخلفية: أزرق ؛
العلوي: 0 بكسل ؛
}
50٪ {
background-color: green؛
العلوي: 50 بكسل
}
100٪ {
لون الخلفية: أصفر.
العلوي: 0 بكسل ؛
}
}

Instructions

أضف حركة أفقية إلى الرسوم المتحركة div . باستخدام خاصية الإزاحة left ، قم بإضافة قاعدة @keyframes بحيث يبدأ قوس قزح عند 0 بكسل عند 0% ، وينتقل إلى 25 بكسل عند 50% ، وينتهي عند -25 بكسل عند 100% . لا تحل محل الخاصية top في المحرر - يجب أن يكون للرسوم المتحركة حركة رأسيًا وأفقيًا.

Tests

tests:
  - text: يجب أن تستخدم قاعدة <code>@keyframes</code> لـ <code>0%</code> الإزاحة <code>left</code> من 0px.
    testString: 'assert(code.match(/0%\s*?{\s*?background-color:\s*?blue;\s*?top:\s*?0(px)?;\s*?left:\s*?0(px)?;\s*?}/gi), "The <code>@keyframes</code> rule for <code>0%</code> should use the <code>left</code> offset of 0px.");'
  - text: يجب أن تستخدم قاعدة <code>@keyframes</code> <code>50%</code> الإزاحة <code>left</code> من 25 بكسل.
    testString: 'assert(code.match(/50%\s*?{\s*?background-color:\s*?green;\s*?top:\s*?50px;\s*?left:\s*?25px;\s*?}/gi), "The <code>@keyframes</code> rule for <code>50%</code> should use the <code>left</code> offset of 25px.");'
  - text: يجب أن تستخدم قاعدة <code>@keyframes</code> لـ <code>100%</code> الإزاحة <code>left</code> من -25 بكسل.
    testString: 'assert(code.match(/100%\s*?{\s*?background-color:\s*?yellow;\s*?top:\s*?0(px)?;\s*?left:\s*?-25px;\s*?}/gi), "The <code>@keyframes</code> rule for <code>100%</code> should use the <code>left</code> offset of -25px.");'

Challenge Seed

<style>
  div {
    height: 40px;
    width: 70%;
    background: black;
    margin: 50px auto;
    border-radius: 5px;
    position: relative;
  }

#rect {
  animation-name: rainbow;
  animation-duration: 4s;
}

@keyframes rainbow {
  0% {
    background-color: blue;
    top: 0px;

  }
  50% {
    background-color: green;
    top: 50px;

  }
  100% {
    background-color: yellow;
    top: 0px;

  }
}
</style>

<div id="rect"></div>

Solution

// solution required