在思想上是要取代的
left
带翻译:
.tooltip {
position: absolute;
border: 1px solid red;
left: 0;
transform:translateX(400px);
}
.text {
max-width: 200px;
}
<div style="border: 1px solid green;width:500px; height: 500px; position:relative">
<div class="tooltip">
<div class="text">test test test test test test test test test</div>
</div>
</div>
如果你想继续使用
,考虑一些负边距以给元素更多的空间:
.tooltip {
position: absolute;
border: 1px solid red;
left: 400px;
margin-right:-400px; /* Make it bigger enough, at least the same as left */
}
.text {
max-width: 200px;
}
<div style=“border:1px纯绿色;宽度:500px;高度:500px;位置:相对“>
<div class=“工具提示”>
<div class=“text”>测试测试</div>
</div>
</div>