How to make so that each next strip was more than the previous?

It is necessary to make so that each next strip was more than the previous, if you have any thoughts, please help!5e275322d8798309828950.png
April 4th 20 at 13:14
1 answer
April 4th 20 at 13:16
Solution
<!DOCTYPE html>
<html>
the <head>
<title></title>
 <style type="text/css">
 .block {
 width: 190px;
 height: 40px;
 background-color: red;
 border: 1px solid black;
}
</style>
</head>
the <body>
 <div class="block"></div>
 <div class="block"></div>
 <div class="block"></div>
 <div class="block"></div>
 <div class="block"></div>
 <div class="block"></div>

 <script type="text/javascript">
 "use strict";

 let blocks = Array.from(document.querySelectorAll(".block"));
 let widthBlock = getComputedStyle(blocks[0]).width.slice(0, -2);
 for (let i = 0; i < blocks.length; i++) blocks[i].style.width = +widthBlock + 20 * i + "px";
</script>
</body>
</html>
Thank you very much! It works! - emmy_Roob66 commented on April 4th 20 at 13:19

Find more questions by tags CSSJavaScript