Padding not being respected, can't figure out why

Hello my dudes, need a helping hand here…

I’ve run into this little issue where the padding of a parent div is not being respected by the child, see video:

Padding not respected by rich text element | 23sec

Link to website in question

Some background info about this parent div and the child element:

The parent element has display: grid with two columns, like this:

image

I admit that CSS Grid is still something I am not comfortable with, but try to use it to get more familiar. So it could be that I defined something in the Grid that is causing this behaviour. You can see that the column width are defined in percentages, that was intentional to keep the proportion between columns in all cases.

The child is a rich text element. Overall I have found styling the rich text element to be difficult, it almost never works as I expect it to, so maybe this is another of the mysterys of the rich text element, or maybe it is something, else, I cannot figure it out.

FYI this rich text child element has overflow: hidden and I have defined a height, these are both on purpose as I want any extra text in there to be clipped beyond the two lines that are showing, as opposed to making the element taller. But I had no intention of doing anything with the width, I would just like the default behaviour where elements respect padding of the parent div.

image

What is going on here, can you advise me please? I think it must be something super simple that I am not understanding about the interaction of these parent and child elements.

Hi, issue was in the settings of grid. It was set to be 27% 73%. I never used % to setup width of my columns in grid, so I am not sure why this issue is happening, but issue is not in Divhunt, this would happen even if you do it in custom coded project.

So one simple solution was to use FR instead of %. So I have set 27fr and 73fr for you, it works same as % in this example. But maybe some better idea is to set values to 1fr and 4fr. That will work like 25%/75%.

2 Likes

Thank you so much @Pakic for helping me to discover the issue and the solution, you are just the best :pray: