Pregunta

I am having trouble with overflowing text in a hidden speech bubble: demo

The text inside the hidden speech bubble over-flows the repeated text 'Hidden message here' and I would like it to stay confined to the area inside the box.

How would I change the code so it shows all of the type stays inside the area of the speech bubble?

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;
}
¿Fue útil?

Solución

You need to remove white-space: nowrap from a.hoverbubble span

a.hoverbubble:hover span {
    white-space: nowrap;
}

This prevents text from wrapping when it reaches the confines of the container.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top