我遇到了一些奇怪的文字对齐,你能不能给我一个问题所在的提示:
我试图创建一个语音泡泡:
.round
{
margin-top: 5px;
border-radius:50%;
background-color:#3d5177;
width:50px;
height:50px;
float: left;
}
.number {
color: white;
padding: 8px 17px;
font-size: 30px;
font-weight: normal;
}
.faq_container {
overflow: hidden;
}
.talkbubble {
left: 80px;
position: relative;
width: 340px;
height: 100px;
padding: 0px;
background: #aaaaaa;
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
border-radius: 10px;
}
.talkbubble:after {
content: '';
position: absolute;
border-style: solid;
border-width: 10px 13px 10px 0;
border-color: transparent #aaaaaa;
display: block;
width: 0;
z-index: 1;
left: -13px;
top: 22px;
}
.talkbubble_text {
display: block;
text-align: left;
padding: 10px;
}
由于
答案 0 :(得分:4)
问题在于<div class="round">
CSS 。元素的宽度将文本推到右侧。
将其添加到.round
类:
.round {
top: 0;
left: 0;
position: absolute;
}
并将其添加到.faq_container
类:
.faq_container {
position: relative;
}
<强> Demo 强>
注意:您可以从float: left;
删除.round
。
答案 1 :(得分:1)
正确的CSS应该是:
.talkbubble {
left: 30px; /* or Whatever you may want the distance from the circle to be */
position: relative;
width: 340px;
height: 100px;
padding: 10px;
background: #aaaaaa;
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
border-radius: 10px;
float: left;
}
.talkbubble_text {
display: inline;
text-align: left;
/* padding: 10px; ( remove this )*/
}
答案 2 :(得分:1)
尝试将float:left
添加到.talkbubble
容器
答案 3 :(得分:1)
你可以试试这个:
.talkbubble_text {
display: inline-block;
text-align: left;
padding: 10px;
line-height:16px;
}
祝你好运...... :)
答案 4 :(得分:1)
我认为问题在于您的最后一行文字与其他文字不符。这是由于您布置代码的方式。您的文字被圆形元素推动,这是一个设定的高度。之后的任何文字都没有被推过,快速解决方法是在数字圆圈的底部添加一个边距。
.round
{
margin-top: 5px;
border-radius:50%;
background-color:#3d5177;
width:50px;
height:50px;
float: left;
margin-bottom : 50px;
}
但最好重新构建一下代码,以便首先阻止这种情况发生。
答案 5 :(得分:1)
更改positions
,将overflow:hidden
添加到.talkbubble_text
以阻止float
左对齐。 Fiddle
答案 6 :(得分:1)
更新:http://jsfiddle.net/Bushwazi/Lf4sr/8/
在这个例子中有很多东西可以清理。有很多额外的HTML。但核心问题是,如果您将float
用于一个部分,则必须同时使用它。因此,您需要将float:left or right
添加到.talkbubble
并删除left
值。
.talkbubble {
/* left: 80px; */
position: relative;
width: 340px;
height: 100px;
padding: 0px;
background: #aaaaaa;
float:left;
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
border-radius: 10px;
}
我在小提琴中做了一些其他的东西来简化和消除额外的html / css。但核心问题是将positioning
与float
混合,只选择一个。