如何让 div 组的背景颜色变宽?

How to make a div group's background colour wider?

我希望 div 的背景颜色超出最小尺寸。每个方向多说10px。

使用 flexBox 得到以下结果:https://gyazo.com/815fcc78086c81cdc46b758c9230e9b9

我的尝试是给 div 添加一个边框,然后将其设为相同的颜色以模拟扩展。看到我的边框 属性 在哪里了吗?这就是尝试。

.volunteer, .organization {
    display: flex;
    color: rgb(193,193,193);
    background-color: rgba(1,48,87,.9);
    border: 15px, solid, rgba(255,48,87,.9);
    justify-content: center;
    flex-direction: column;
    margin: 5%;
}

有办法吗?我看到的唯一其他方法是在 photoshop 中制作背景,但这看起来太额外了。

您要找的是padding。您可以简单地添加这一行:

padding: 10px;

并根据需要调整数字。

您好,请尝试添加 padding

padding 5px;

或您喜欢的任何数字