2

code is like below,

const renderInfo = () => {
    return (
        <>
            <div>Name</div>
            <div>Name1</div>
            <div>Type</div>
            <div>Type1</div>
        </>
    );
};

I want it to display like below,

enter image description here

but is currently shown like this with above code enter image description here

Could someone help me fix this alignment. thanks.

2
  • Did you try to fix it? You're expected to at least try then come back with questions about issues if you have them. Commented Aug 17, 2021 at 13:45
  • Does this answer your question? React and Flex layout how to use them Commented Aug 17, 2021 at 13:46

2 Answers 2

2

Or you can have styles inside div like so:

<div style={{ display: "block" }}>
  <div>Name</div>
  <div>Name1</div>
  <div>Type</div>
  <div>Type1</div>
</div>

Sign up to request clarification or add additional context in comments.

Comments

1

Wrap it inside a container after that you can use flexbox, display: block etc.

Using Flexbox

.container {
  display: flex;
  flex-direction: column;
}
<div class="container">
  <div>Name</div>
  <div>Name1</div>
  <div>Type</div>
  <div>Type1</div>
</div>

Using display: block

.container {
  display: block;
}
<div class="container">
  <div>Name</div>
  <div>Name1</div>
  <div>Type</div>
  <div>Type1</div>
</div>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.