我有一个绝对定位的div(这不能改变)。该div具有最大和最小宽度。
我希望实现的是div延伸到其内容并且只有当它超过宽度时才开始使用新行。
HTML:
<div class="black_tooltip_container ">
some text in here, it can be anything!
</div>
CSS:
position:absolute; min-width:10px; max-width:150px;
我所看到的:
_____________
| some |
| text |
| in |
| here, |
| it |
| can |
| be |
| anything! |
_____________
我想看到的内容:
width: 150px
_______________________________
| some text in here, it can |
| be anything! |
______________________________
修改 问题解决了。问题是我没有意识到div被嵌套在一个具有相对位置和宽度的div中很远:50px;
从父母那里删除后,它就像指定的
一样答案 0 :(得分:1)
你应该有什么工作:
<div class="black_tooltip_container ">
some text in here, it can be anything!
</div>
.black_tooltip_container {
border:1px solid;
min-width:10px;
max-width:150px;
position:absolute;
}
请在此处查看: