所以基本上我想在子div的中间放置一个子div,并添加一些填充,当子溢出时,我仍然希望填充在其中。
到目前为止,我可以使用overflow: hidden
将内容隐藏在父div之外,但是我希望它可以使内容仅溢出到元素填充的开头。
这是我的问题的有效示例:
.post-grid {
background-color: #1D7B99;
width: 100px;
height: 40px;
padding: 1em;
text-align: center;
overflow: hidden;
}
.postview-center {
display: inline-block;
overflow: hidden;
}
.postview-center a {
color: white;
text-decoration: none;
}
<div class="post-grid">
<div clas="postview-center">
<a href="www.stackoverflow.com"> Thisis a very long title that will overflow and I don't want the overflowed text to affect the padding </a>
</div>
</div>