如何删除ANTD抽屉中的边距

发布于 2025-01-19 20:35:06 字数 442 浏览 3 评论 0原文

我使用antd抽屉。 抽屉的左右边距无法移除,因此步骤组件被左右推了几个边距(红色圆圈)。

然后,antd 步骤蓝色滑块也有一个边距(绿色圆圈)。

我尝试放置 margin:0pxpadding:0px 但似乎无法解决这些问题。

代码沙箱: https:// codesandbox.io/s/basic-antd-4-19-5-forked-iq13nx?file=/index.js

enter image description here

I use a antd drawer.
The margin left and right of the drawer couldn't be removed, so the steps component is pushed a few margins from left and right (red circle).

Then, The antd steps blue slider is also has a margin (green circle).

I tried putting margin:0px and padding:0px but doesn't seems to fix these issues.

Code sandbox: https://codesandbox.io/s/basic-antd-4-19-5-forked-iq13nx?file=/index.js

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

无语# 2025-01-26 20:35:06

您还可以使用 Drawer 属性“bodyStyle”来修改正文的样式:

        <Drawer          
          bodyStyle={{ padding:'0px' }}
        >
//...
        </Drawer>

You can also use the use the Drawer props "bodyStyle" to modify the style of the body:

        <Drawer          
          bodyStyle={{ padding:'0px' }}
        >
//...
        </Drawer>
星軌x 2025-01-26 20:35:06

如果要删除红色边距,则需要左右设置填充到0,并在垂直方面保持24px:

.ant-drawer-body {
    flex-grow: 1;
    padding: 24px 0; // <-- This 0 do the work
    overflow: auto;
    font-size: 14px;
    line-height: 1.5715;
    word-wrap: break-word;
}

对于蓝色下划线(图像中的绿色信号),必须更改此样式:

.ant-menu-horizontal > .ant-menu-item::after, .ant-menu-horizontal > .ant-menu-submenu::after {
    position: absolute;
    right: 0; // <-- 0 instead 20px
    bottom: 0;
    left: 0; // <-- 0 instead 20px
    border-bottom: 2px solid transparent;
    transition: border-color 0.3s cubic-bezier(0.645, 0.045, 0.355, 1);
    content: '';
}

If you want remove the red margin, you need set padding left and right to 0 and remain the 24px in vertical sides:

.ant-drawer-body {
    flex-grow: 1;
    padding: 24px 0; // <-- This 0 do the work
    overflow: auto;
    font-size: 14px;
    line-height: 1.5715;
    word-wrap: break-word;
}

For the blue underscore (your green signal in the image), you must change this style:

.ant-menu-horizontal > .ant-menu-item::after, .ant-menu-horizontal > .ant-menu-submenu::after {
    position: absolute;
    right: 0; // <-- 0 instead 20px
    bottom: 0;
    left: 0; // <-- 0 instead 20px
    border-bottom: 2px solid transparent;
    transition: border-color 0.3s cubic-bezier(0.645, 0.045, 0.355, 1);
    content: '';
}
顾冷 2025-01-26 20:35:06

BodyStyle现在已弃用
使用代码>

<Drawer
   styles={{
      body: {
         padding: 0
      }
    }}
/>

bodyStyle now is deprecated
Use styles:

<Drawer
   styles={{
      body: {
         padding: 0
      }
    }}
/>

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文