嘗試在文本換行的情況下爲此工具提示應用最大寬度jsfiddle,但它應用默認寬度。CSS3:工具提示最大寬度與Word Wrap
HTML:
<div id="container" style="margin: 167px 135px 0px 0px; height: 400px">
<a class="tooltip" tip="television">content1</a>
<a class="tooltip" tip="By noon yesterday, news television screens were filled with visuals of a Delhi we have been familiarized with over the past year.">content2</a>
</div>
CSS:
.tooltip{
display: inline;
position: relative;
white-space: pre-wrap; /* css-3 */
margin: 20px 20px 20px 20px;
height: 30px;
width: 50px
}
.tooltip:hover:after{
background: #8FBC8F;
border-radius: 5px;
bottom: 26px;
color: #000;
content: attr(tip);
left: 20%;
padding: 5px 15px;
position: absolute;
z-index: 98;
width:auto;
min-width:50px;
max-width:500px;
}
.tooltip:hover:before{
border: solid;
border-color: #8FBC8F transparent;
border-width: 6px 6px 0 6px;
bottom: 20px;
content: "";
left: 50%;
position: absolute;
z-index: 99;
}
當工具提示文本是越來越字包裹,寬度應去到一些最大寬度,而不是默認的寬度,使其方便閱讀。
這個jsfiddle工作時,我把顯示器:內聯表;像下面
.tooltip:hover:after{
:
:
display: inline-table;
}
但它只能在Chrome中,而不是在IE
你沒見過小提琴嗎? http://jsfiddle.net/Seenu/yjYW4/當工具提示中的文本獲得單詞包裝時,寬度應該達到某個最大寬度而不是默認寬度,以便便於閱讀。 – Seenu