css - 隐藏对话气泡中的溢出文本

标签 css text hidden

我在隐藏对话气泡中溢出文本时遇到问题:demo

隐藏对话气泡内的文本溢出了重复的文本“此处隐藏消息”,我希望它保持在框内的区域内。

我如何更改代码以显示所有类型都位于对话气泡区域内?

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/

相关文章:

javascript - 具有粘性标题和水平滚动的多个表

javascript - 鼠标悬停时如何在侧边栏上显示子菜单栏?

Java - 滚动到 JTextArea 内的特定文本

android - 使用 setMessage() 在 AlertDialog 中显示多行文本和变量

sorting - 在 PowerShell 中对非常大的文本文件进行排序

javascript - 使用 CSS 和 jQuery 添加上一个/下一个按钮以滚动容器

ruby-on-rails - 有没有办法扩展 SASS 预处理器来任意操作每个声明的属性?

javascript - 如何创建隐藏的 div,以及如何在其中使用 swf 文件?

javascript - 给隐藏的div效果出现

Javascript 不关闭菜单