简体   繁体   English

react组件中如何使用antd分隔线来分隔屏幕的两侧?

[英]How to use antd divider to separate two sides of the screen in a react component?

I am using antd and would like the vertical divider to split the two sides of my screen.我正在使用 antd 并希望垂直分隔线将屏幕的两侧分开。 The two sides are in fact separated by different Col components.两侧实际上是由不同的Col组件隔开的。 They currently look something like this:它们目前看起来像这样:

 class Example extends React.Component {
   render () {
     return (
      <Row>
        <Col span={11}>
          CONTENT ONE SIDE
        </Col>
        <Col span={2}>
          <Divider type='vertical'/>
        </Col>
        <Col span={11}>
          CONTENT OTHER SIDE
        </Col>
      </Row>
     )
   }
 }

The issue here is that the Divider is barely appearing.这里的问题是 Divider 几乎没有出现。 I would like it to go all the way down where the content ends.我希望它一直到内容结束的地方。 Instead, it is just a tiny little line.相反,它只是一条很小的小线。

This is a screenshot of what it currently looks like:这是它当前外观的屏幕截图:

在此处输入图片说明

You can barely see the divider in the middle.你几乎看不到中间的分隔线。

How can I make the vertical divider be as long as the content?如何使垂直分隔线与内容一样长?

Thanks!谢谢!

您可以将分隔线的height设置为100% ,请参阅此沙箱

    <Divider type="vertical" style={{ height: "100%" }} />

Mine doesn't work with the above answers.我的不适用于上述答案。 After a little bit of work.经过一点工作。 I finally got this below code to work.我终于让下面的代码起作用了。

< Divider
   type="vertical"      style={{ height: "100px", backgroundColor: "#000" }}
/>

height 100%高度 100%

    <Row>
      <Col span={11}>
        CONTENT ONE SIDE
        <br />
        CONTENT ONE SIDE
        <br />
        CONTENT ONE SIDE
        <br />
      </Col>
      <Col span={2}>
        <Divider type="vertical" style={{ height: "100%" }} />
      </Col>
      <Col span={11}>CONTENT OTHER SIDE</Col>
    </Row>

https://codesandbox.io/s/antd-create-react-app-forked-rzp10?file=/index.js:181-499 https://codesandbox.io/s/antd-create-react-app-forked-rzp10?file=/index.js:181-499

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在单独的React组件脚本中使用React库? - How to use react libraries in separate React component script? 如何在反应中使用antd表中的自定义分页? - how to use custom pagination in antd table in react? 如何使用单独的函数来动态组合一个 React 组件? - How to use separate functions to dynamically compose a React component? 如何使用来自单独组件文件的反应路由器导航链接? - How to use react router navigation links from separate component file? 滚动 antD 组件 React 的 Dropdown - Scroll on Dropdown of antD component React 如何在反应可拖动中使元素两侧有界并且两侧打开? - How to make an element two sides bounded and two sides open in react-draggable? React:如何在 antd 库的 select 组件上设置初始值? - React : How to set initial values on select component of antd library? 如何在 Ant Design (Antd), React js 中获取 Dropdown 组件的值 - How to get value of Dropdown component in Ant Design (Antd), React js (react,antd,card) 如何使用 antd 卡组件阻止 onclick function 操作按钮? - (react,antd,card) How can I block the onclick function from action buttons with antd card component? React Native + Typescript:如何在堆栈屏幕组件中使用 toggleDrawer? - React Native + Typescript: How to use toggleDrawer in a stack screen component?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM