#tooltip
{
position: absolute;
width:auto;
min-width:50px;
max-width:250px;
padding:10px;
background-color:#eee;
border:1px solid #aaa;
}
Run Code Online (Sandbox Code Playgroud)
基于这种风格,我希望我的工具提示缩小或增长以适应内容,低至50px或高达250px.但是,当内容换行到下一行时,max-width属性似乎超出了我的width属性.当句子末尾的单词很长时,它看起来像留下了一堆填充(见截图),这是一种美学的东西.这是正常的行为吗?

div当自动换行时是否可以调整元素的大小?出于演示目的,请查看类似问题中的示例:
.mypost {
border: 1px solid Peru;
margin: auto;
min-width: 200px;
display: inline-block;
background: red;
}
.test {
margin: 10px;
background: cyan;
}Run Code Online (Sandbox Code Playgroud)
<div class="mypost">
<div class="test">I represent the imagdfv fdvdsdfsdfve.</div>
</div>Run Code Online (Sandbox Code Playgroud)
如果将窗口缩小以便进行自动换行,您将看到文本右侧有一个蓝色的空白区域。相反,我希望蓝色区域减少,直到到达第一行的最后一个字母。
(在这张图片中,我强制自动换行。我希望蓝色区域缩小。)
这可能吗?