简体   繁体   中英

How can I vertically align data by 3 when using the react map function?

I have an array object called farm and this data has a total of 10 objects, so when the map function is executed, "hambuger" comes out 10 times.

At this point, I want to vertically align the hamburger data by 3 so that there are 4 lines in total. Of course, there is only one data in the last line.

like this

 hamburger  hamburger hamburger

 hamburger  hamburger hamburger

 hamburger  hamburger hamburger
 
 hamburger

But when I run my code, it all aligns vertically.

like this image

在此处输入图像描述 this is my code

const Container = styled.div`
  background: lightblue;
  width: 100%;
  display: inline-block;
  flex-direction: row;
`;

const FarmBox = styled.div`
  background-color: lavender;
  display: inline-block;
  flex-wrap: wrap;
  width: 10%;
  height: 13%;
  flex-direction: row;
`;

  return (
    <>
    
      {farm.map((v, i) => {
        return (
          <Container key={i}>
            <FarmBox>hambuger</FarmBox>
          </Container>
        );
      })}

    </>
  );
};

export default About;

How can i change my code?

becouse Container is Div and it has 100% width, change this

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM