我有这段 HTML
<div class="box">
<div class="box-header">
<h4 class="box-header-title">CONTENT</h4>
</div>
<!-- rest of box -->
</div>
我有这个CSS:
.box {
display: inline-block;
min-width: 360px;
position: relative;
}
.box-header {
color: #fff;
}
.box-header-title {
padding: 0 2%;
}
我想要什么:.box.header-title
根据当前宽度调整它的填充.box-header-title
而不是.box
现在,如果.box
是500px
计算值,则填充将在 计算10px
。我希望它以元素的当前宽度而不是父框计算。