如何在React-Bootstrap组件中将padding/margin作为props传递 [英] How to pass padding/margin as props in React-Bootstrap components

查看:101
本文介绍了如何在React-Bootstrap组件中将padding/margin作为props传递的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用React-Bootstrap作为道具来应用边距和填充.

I am trying to apply margins and paddings with React-Bootstrap as props.

我通过了文档,但是没有找到任何在其中添加填充或边距的提示它在官方引导文档中( 3th 第4个).我知道它对Bootstrap 4的支持不佳,因此尝试了两者.

I passed the docs through but haven't found any mention adding padding or margin in there as it is in official bootstrap docs (3th and 4th). I know it doesn't support well Bootstrap 4, so tried with both.

我试图将参数传递为p={1}paddingxs={5}mt='1',但它无法识别任何参数.更多信息试图在React-Bootstrap文件夹中找到任何 Spacing 元素,但失败了.

I tried to pass params as p={1}, paddingxs={5} or mt='1' but it doesn't recognize any of them. More over tried to find any Spacing element in React-Bootstrap folder, but failed.

填充和边距用作类名.但是我觉得没有Bootstrap类就一定有办法.必须有一种财产.

Paddings and margins work as classnames. But I feel there must be a way to it without Bootstrap classes. There must be a kind of property.

推荐答案

您可以使用默认的React样式添加边距和填充:

You can add margin and padding by using default React's style:

const divStyle = {
  marginLeft: '10px',
};

function HelloWorldComponent() {
  return <div style={divStyle}>Hello World!</div>;
}

此处

这篇关于如何在React-Bootstrap组件中将padding/margin作为props传递的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆