freeCodeCamp/curriculum/challenges/arabic/01-responsive-web-design/css-grid/reduce-repetition-using-the...

3.3 KiB

id title challengeType videoUrl localeTitle
5a94fe3669fb03452672e45f Reduce Repetition Using the repeat Function 0 تقليل التكرار باستخدام تكرار الوظيفة

Description

عند استخدام grid-template-columns grid-template-rows و grid-template-rows لتعريف بنية الشبكة ، فإنك تقوم بإدخال قيمة لكل صف أو عمود قمت بإنشائه. لنفترض أنك تريد شبكة ذات 100 صف من نفس الارتفاع. ليس عمليًا إدراج قيم 100 بشكل فردي. لحسن الحظ ، هناك طريقة أفضل - باستخدام وظيفة repeat لتحديد عدد المرات التي تريد تكرار عمودك أو صفك ، متبوعة بفاصلة والقيمة التي تريد تكرارها. في ما يلي مثال على ذلك من شأنه إنشاء شبكة الصف 100 ، كل صف بطول 50 بكسل.
صفوف قالب الشبكة: كرر (100 ، 50 بكسل) ؛
يمكنك أيضًا تكرار عدة قيم باستخدام وظيفة التكرار ، وإدراج الدالة بين القيم الأخرى عند تعريف بنية الشبكة. إليك ما أعنيه:
أعمدة قالب الشبكة: كرر (2 ، 1fr 50px) 20 بكسل ؛
هذا يترجم إلى:
أعمدة قالب الشبكة: 1fr 50px 1fr 50px 20px؛
ملحوظة
1fr 50px يتكرر مرتين يليه 1fr 50px .

Instructions

استخدم repeat لإزالة التكرار من خاصية grid-template-columns .

Tests

tests:
  - text: يجب أن <code>container</code> فئة <code>container</code> <code>grid-template-columns</code> خاصية <code>grid-template-columns</code> التي تم تعيينها لتكرار 3 أعمدة بعرض <code>1fr</code> .
    testString: 'assert(code.match(/.container\s*?{[\s\S]*grid-template-columns\s*?:\s*?repeat\s*?\(\s*?3\s*?,\s*?1fr\s*?\)\s*?;[\s\S]*}/gi), "<code>container</code> class should have a <code>grid-template-columns</code> property that is set to repeat 3 columns with the width of <code>1fr</code>.");'

Challenge Seed

<style>
  .item1{background:LightSkyBlue;}
  .item2{background:LightSalmon;}
  .item3{background:PaleTurquoise;}
  .item4{background:LightPink;}
  .item5{background:PaleGreen;}

  .container {
    font-size: 40px;
    min-height: 300px;
    width: 100%;
    background: LightGray;
    display: grid;
    /* change the code below this line */

    grid-template-columns: 1fr 1fr 1fr;

    /* change the code above this line */
    grid-template-rows: 1fr 1fr 1fr;
    grid-gap: 10px;
  }
</style>

<div class="container">
  <div class="item1">1</div>
  <div class="item2">2</div>
  <div class="item3">3</div>
  <div class="item4">4</div>
  <div class="item5">5</div>
</div>

Solution

// solution required