我在隐藏对话气泡中溢出文本时遇到问题:demo
隐藏对话气泡内的文本溢出了重复的文本“此处隐藏消息”,我希望它保持在框内的区域内。
我如何更改代码以显示所有类型都位于对话气泡区域内?
HTML:
<div id="container"><a href="#" class="hoverbubble">Hover over me!<span><p>Hidden message here. Hidden message here. Hidden message here. Hidden message here. Hidden message here.Hidden message here.Hidden message here.</p></span></a></div>
CSS:
#container {
background-color: #FF0;
margin: 200px;
float: left;
height: 200px;
width: 200px;
text-align: center;
font-family: Arial, Helvetica, sans-serif;
font-size: 16px;
position: relative;
}
a.hoverbubble {
text-decoration: none;
}
a.hoverbubble span {
display: none;
position: absolute;
left: 3%;
top: 40%;
}
a.hoverbubble:hover span {
display: block;
position: absolute;
padding: .5em;
content: attr(title);
min-width: px;
text-align: center;
width: 180px;
height: 100px;
white-space: nowrap;
top: -125px;
background: rgba(0,0,0,.8);
-moz-border-radius: 10px;
-webkit-border-radius: 10px;
border-radius: 10px;
color: #fff;
font-size: 0.86em;
font-family: Arial, Helvetica, sans-serif;
}
a.hoverbubble:hover span:after {
position: absolute;
display: block;
content: "";
border-color: rgba(0,0,0,.8) transparent transparent transparent;
border-style: solid;
border-width: 10px;
height: 0;
width: 0;
position: absolute;
bottom: -20px;
left: 6.1em;
}
最佳答案
您需要从 a.hoverbubble span
中删除 white-space: nowrap
a.hoverbubble:hover span {
white-space: nowrap;
}
这可以防止文本在到达容器边界时换行。
关于css - 隐藏对话气泡中的溢出文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22988743/