How to remove inner padding inside a container

Hi everyone,

I have a top navigation menu looking like this:

and on mobile looking like this:

It’s a great structure to let the user navigate to the next or previous component or go a level up.

The green part is a custom component (and typically I would put it to a similar colored background but I made the background white to make it clear).

To make the interface a bit sleeker I would want the component to go up to the edges of the container. The container is the white background btw.

Is it possible to remove the internal padding of a container using custom css?

Many thanks for your support!!!

Best regards,

Tim

Yes you can. But we would need to see the HTML structure of that component.

By the way, is this an AI component? You could try use an AI component with three actions. It would let you do more advanced things.

Hi Maxime,

What do you mean with the HTML structure of the component?
Do you mean I would need to inspect the page, find the object and share that?
This is the custom component:

But in hindsight I could also simply do it with a button block with 3 buttons like this: (I would just need to make a workaround to make sure on mobile it only shows the icons and if the action is not available it will still show the button).

Only now it eats up too much screen real estate so would like to have it without the default margins around it.

Thanks for having a look!

Best regards,

Tim

Exactly

1 Like

Containers have padding, and AI components have padding. Container padding can be adjusted with CSS. For the AI component, I usually instruct it to set container margins to zero or a small number of pixels.

I also believe you can get more specific with your instructions. You can do something like mb-2 or pb-2 to adjust bottom margin or padding to whatever units of measure it’s using. Default for margins seems to be 4. I think you can work out what mb and pb mean (ie margin bottom or padding bottom) and do the same for top, left and right. I only do that if I need to adjust a specific margin. Other than than just asking to reduce margins helps a lot.

1 Like

Hi Maxime,

Is this something you can work with?

Btw do you know if the margin is defined in the container or in the component?
I assumed it was in the container since the AI component didn’t react to me prompting requesting to make the margins smaller.

Best regards,

Tim

Hi Jeff, thanks for the tips but I just did that and it changes nothing.
In the prompt of the AI component I already asked to remove padding / margins, so I guess it’s in the container.
If if set the margin larger using mb-6 / pb-6 it actually get’s larger, but if I ask it to go to 0 it remains as it was before.

btw I just tried to fix it using chatGPT however I’m able to target the container.
I called it the CSS class no-padding
and applied the following piece of code in my custom css settings:

/* Remove all padding and margins from the container */
.no-padding {
padding: 0 !important;
margin: 0 !important;
}

But it only removed the bottom padding.
I tried a few other things to remove the top padding as well but these were without succes.

1 Like

These are infuriating. I have problems like that a bunch of times with this component, I find it just easier to copy the whole component’s HTML, feed it to an AI model, tell it to do what you want, then copy the new code and start a component from scratch.

2 Likes

I don’t have any hard set rules for setting margins. It’s usually trial and error. I have gone so far as to set margins to -15px in some cases.

2 Likes

Ok thanks @Jeff_Hager I think I learned something here :slight_smile:
Didn’t expect these margins were allowed to be negative :sweat_smile:
Scherm­afbeelding 2025-02-17 om 09.05.14

this did the trick:
.no-padding {
/* negative top margin of 3px */
margin-top: -15px !important;
margin-bottom: 0 !important;
padding: 0 !important;
}

2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.