首页 > 解决方案 > 多行块的百分比填充

问题描述

我可以根据多行文本的高度设置填充吗?例如,我对每条新线的需求padding-top越来越div.p少。

 .modal{
    width: 200px;
    height: 200px;
    border: 1px solid gray;
    font-size: 16px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-evenly;
    float: left;
}
.p{
    position: relative;
}
.p:before{
    content: '';
    display: block;
    position: relative;
    width: 100%;
    height: calc((120px - 100%) / 5); /*not working*/
}
<div class="modal">
    <div class="text">
        <div class="h"><b>Header</b></div>
        <div class="p">Multiline text. Multiline text.</div>
    </div>
    <button>Button</button>
</div>

更多示例:https ://jsfiddle.net/1n4bdtea/ (我想要文本和标题之间的填充〜10x 1 行和〜5px 4 行)

标签: cssresponsive-designheightpadding

解决方案


推荐阅读