使用组件的 Ant Design 样式与使用 css 类的样式
我最近开始使用 Ant Design,我注意到人们可以使用 React 组件和 css 类来解决问题。在文档中我找不到任何有关 css 类的内容,但我个人更喜欢 css 类方法。如何了解有关可用 css 类的更多信息,以便避免导入所有这些组件?
import 'antd/dist/antd.css';
import { Row, Col } from 'antd';
<Row>
<Col xs={24} xl={8}>
One of three columns
</Col>
<Col xs={24} xl={8}>
One of three columns
</Col>
<Col xs={24} xl={8}>
One of three columns
</Col>
</Row>
或者:
<div className="ant-row">
<div className="ant-col ant-col-xs-24 ant-col-xl-8">
One of three columns
</div>
<div className="ant-col ant-col-xs-24 ant-col-xl-8">
One of three columns
</div>
<div className="ant-col ant-col-xs-24 ant-col-xl-8">
One of three columns
</div>
</div>
I recently started using Ant Design and I noticed people can solve the problem with React Components and css classes. In the docs I can't find anything regarding the css classes, But I personally prefer the css classes approach. How can I learn more about the available css classes so I can avoid importing all those Components?
import 'antd/dist/antd.css';
import { Row, Col } from 'antd';
<Row>
<Col xs={24} xl={8}>
One of three columns
</Col>
<Col xs={24} xl={8}>
One of three columns
</Col>
<Col xs={24} xl={8}>
One of three columns
</Col>
</Row>
or:
<div className="ant-row">
<div className="ant-col ant-col-xs-24 ant-col-xl-8">
One of three columns
</div>
<div className="ant-col ant-col-xs-24 ant-col-xl-8">
One of three columns
</div>
<div className="ant-col ant-col-xs-24 ant-col-xl-8">
One of three columns
</div>
</div>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不认为 Ant 适合与类一起使用。 React 组件保证 API、HTML 结构和 javascript 逻辑能够很好地协同工作。您可以尝试使用与类相同的 HTML 结构来重现 UI,但这并不容易维护。
如果您正在寻找基于 CSS 的框架,您应该查看 Tailwind CSS 或类似的库。
I don't think Ant is meant to be used with classes. React components guarantee the API, the HTML structure and the javascript logic works well together. You could try to reproduce the UI using the same HTML structure with the classes but that won't be easy to maintain.
If you're looking for a CSS based framework, you should look at Tailwind CSS or similar libraries.