Ways to eliminate the default padding in Ant Design

I have implemented a collapsible sidebar. However, the content inside the sidebar is automatically adding padding values of 16px on the top, right, bottom, and left. I want to remove this automatic padding.

 render() {
return (
  <div className="common-coll-bar">
    <Collapse >
      <Panel header="Present Staffs" style={customPanelStyle}>
        <p style={{ height: 550, color: '#131D43', background: '#607B7E', padding: 0 , margin: 0 }}> {text}</p>
      </Panel>

    </Collapse>
  </div>
);

}

Could anyone provide assistance with this issue?

Answer №1

To override the current styling, you will need to manually make changes.

One way to do this is by adding a custom class to the panel:

 <Panel header="This is panel header 1" key="1" className="custom">

Then, you can incorporate the following code in your less file:

.custom {
  .ant-collapse-content-box {
    padding: 0;
   }
}

For a visual example, check out this link: https://codepen.io/kossel/pen/gooQqv

Answer №2

When utilizing CSS modules:

.collapsePanel {
    :global(.ant-collapse-content-box) {
        padding: 0 !important;
    }
}

Simply import the file and use it like this:

 <Collapse className={css["collapsePanel"]}>
    ...

This method was the only one that worked for me, in conjunction with

<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="badbd4cedefacc8f94c2">[email protected]</a>

Answer №3

In order to customize the appearance of antd, it is important to theme it properly. Simply following the suggested solution by Yichaoz may only apply to certain elements with that specific class, leading to a more difficult maintenance process. It is necessary to refer to this resource https://ant.design/docs/react/customize-theme for a more suitable solution.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Personalized text hues for your WordPress product page

As someone who is new to all of this, please keep that in mind :/ I decided to remove the "add to cart" button from my theme (blocksy) so I could insert my own buttons within the product page under the "short description" text. I needed two "download" but ...

Transferring content files from a nuget directory to a specific destination folder

I am dealing with a nuget package that includes css files as content. My goal is to have these css files copied to a specific directory upon importing the package into a project, without requiring the project's structure to match exactly. Is there a ...

``Are there any thoughts on how to troubleshoot display problems specifically on mobile

Whenever I use Safari on iOS for my web application, I encounter strange rendering issues. It's odd because the majority of the time everything functions as it should, but every now and then these bugs crop up with no discernible pattern. Examples th ...

Unable to move up and down in my iframe

I am currently working on an Instagram page that is visible through an iframe. Everything seems to be functioning fine on my iMac, but I am facing an issue with scrolling on my iPhone and iPad? After reviewing my code, I couldn't find any hidden over ...

Steps to reposition an element with absolute positioning to the upper left corner of the screen

I am currently in the process of creating a hamburger menu without using JavaScript, which should drop down from the top to the bottom when clicked. The burger menu is situated at the top right corner of the screen, but every time I try to drop down the na ...

Tips for changing the display of input type submit value on hover using CSS in a React Component

I need help with a form that has an <input type="submit" element where the value is set dynamically based on currIntValue. My goal is to change the displayed value to 'Search' when hovering over the input, instead of showing currIntValue. I ...

What is the best choice for exporting components?

When it comes to creating my own components, I tend to use names like this: <Menu> <MenuItem/> <MenuItem/> </Menu> However, when using the AntDesign library, their menu is structured like this: <Menu> <Menu.Ite ...

Building a drop-right menu with Bootstrap within a dropdown menu - a step-by-step guide

I added a drop-down link to the site's navigation bar, but I'm trying to make one of the drop-down items a dropright link within another drop-down menu in the navigation bar. How can I achieve this? I tried using the code below, but the second d ...

Showcase three elements next to each other on the same row (Photo Gallery, Description, and Contact Form)

I am attempting to showcase three divs in a single line while working on a Subtheme for the Drupal 8 Bootstrap Theme. These particular divs are fields nested within a view known as viewproducts. The divs include: Juicebox Photo Gallery; ...

Triggering scroll snapping in CSS based on a different user action than just scrolling

Take a look at this example: https://codesandbox.io/s/spring-wood-0bikbb?file=/src/styles.css Try this to recreate the issue: Click on the input at the top Scroll to the bottom, then click on an empty area Observe how the screen jumps back up to the top ...

Expanding div that adjusts to content size and expands to fit entire page

Appreciate your help. I'm currently facing an issue with the "content" and "footer" sections within the "wrapper" element. Below are the styles for these elements: #content { width: 100%; min-height: 100%; position: relative; background- ...

Issues with Laravel 8's datatable scripts causing dysfunction

In my practice with the AdminBSB template, I am facing an issue where the Jquery datatable plugin JS is not functioning properly in my blade template. I aim to achieve a datatable layout similar to this example: https://i.sstatic.net/krfPl.jpg However, t ...

Finding an element based on its styling attribute, such as its position on the left or right side

One particular block that caught my eye is the slider element: <div id="sliderDispo" class="slider slider-dispo" data-slider-init="" data-slider-color="#0077b5 #EC6E31 #E40B0B" data-slider-step="33" > <div class="slider__interval" ...

What is the best way to set up unique body backgrounds for each page in WordPress?

My website consists of various pages named as : page-X.php page-Y.php page-Z.php These three pages mentioned above require unique background colors. However, the remaining pages/posts on my site inherit their background-color from the style.css file. ...

Avoid filling the container with an excessive amount of grids while maintaining the correct aspect ratio

I encountered a situation where I needed to dynamically create a grid with square grids of dimensions MxN. Below is the code snippet for achieving this: rerender = (event) => { const height = document.getElementById("y-input").value; const width ...

What is the method for centering text above and below an image in the vertical middle?

I'm struggling to create a vertical center-aligned image gallery on my website with "PREVIOUS" and "NEXT" links for easy navigation. Despite multiple attempts, I can't seem to get it right. Can someone guide me on how to achieve this effect? ...

The E.js Template encountered an error with an unexpected token "else"

I am in the process of creating a website quickly using e.js & Express. However, I am encountering some problems when trying to use an if-else statement within e.js tags. The if statement works fine, but as soon as I add an else statement, things start t ...

Using jQuery to create animated effects for hidden input fields

The struggle to smoothly animate and fade in a hidden text field can be witnessed in this example. The goal is to seamlessly move all elements around the text field and button while fading in/out the hidden element. However, it appears that towards the en ...

What is the best way to ensure a division's height matches that of the window using CSS?

Is it possible to create a division that covers the total width and height of the screen using just CSS without relying on JavaScript or jQuery? <div id="all"></div> I have tried setting the width and height of the element to 100%, but I am s ...

How to Fix Tags Moving to Bottom when Hovered Due to Limited Space?

Recently, I've been facing an issue with the tags on my website. When I hover over them, a remove icon appears, causing the tags to increase in size. This results in a problem where, if I hover over the rightmost tag and there isn't enough space ...