基本上,我正在构建一个游戏。在我的游戏中,我不希望玩家能够互相交谈。你有一个人物,当你说话时,你的文字会在你的角色上出现一个说话气泡 div。
我的困境是,当我在气泡中输入太多文本时,气泡会在字符上方扩展。所以我希望泡沫向上生长。我一直在想办法在 JS 和 CSS 中做到这一点,但我不得不放弃并问你们。
这是一个例子:http: //jsfiddle.net/tDrNN/
HTML
<div class="wrapper">
<div class="character1" style="position: absolute; top: 124px; left: 392px; width: 36px; height: 36px; background-color: blue;">
<div class="bubble"><span>Hi my name is Mads</span></div>
</div>
<div class="character2" style="position: absolute; top: 124px; left: 192px; width: 36px; height: 36px; background-color: blue;">
<div class="bubble"><span>Hi my name is MadsHi my name is MadsHi my name is MadsHi my name is MadsHi my name is MadsHi my name is Mads</span></div>
</div>
</div>
CSS
.bubble {
position: relative;
background-color:#eee;
margin: 0;
padding:2px;
min-width:100px;
-moz-border-radius:10px;
-webkit-border-radius:10px;
-webkit-box-shadow: 0px 0 3px rgba(0,0,0,0.25);
-moz-box-shadow: 0px 0 3px rgba(0,0,0,0.25);
box-shadow: 0px 0 3px rgba(0,0,0,0.25);
top: -80px;
}
.bubble:after {
position: absolute;
display: block;
content: "";
border-color: #eee transparent transparent transparent;
border-style: solid;
border-width: 10px;
height:0;
width:0;
position:absolute;
bottom:-19px;
left:1em;
}
.bubble span {
height: auto !important;
color: #000 !important;
font-family: verdana;
}