css - 如何使用 css 和 react 在 div 中一个接一个地返回对齐元素?

标签 css reactjs

代码如下,

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

我希望它显示如下,

enter image description here

但目前上面的代码显示如下 enter image description here

有人可以帮我解决这个对齐问题吗?谢谢。

最佳答案

或者你可以在 div 中添加样式,如下所示:

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

关于css - 如何使用 css 和 react 在 div 中一个接一个地返回对齐元素?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68818477/

相关文章:

css - 如何通过 "z-index"使菜单始终位于内容之上

html - 使用 css background-image 属性时如何获取图像?

node.js - 在 React 组件的 setState 中使用 Math.random 时组件渲染不正确

reactjs - React警告: Each child in an array or iterator should have a unique "key" prop.检查 `App`的渲染方法

javascript - 根据 url 中给出的值,使用 React 路由动态渲染 React 组件

html - Div 标签(动画箭头)没有停留在页面的左下角,就在我的页脚上方

javascript - 使用 z-index 将 div 中的子元素发送到背景,但仍然使它们可见

reactjs - ComponentDidMount 与 ComponentWillMount?

reactjs - 使用 Travis for React 如何不将警告视为错误

javascript - JS调试流程?