Div长篇文章在Div中重叠?

时间:2014-05-07 05:32:13

标签: html css html5 css3

我想要一个最小高度的div盒:33px;当大于那个高度时,自动换行以增加高度。这是一个有效的小提琴http://jsfiddle.net/PzfF7/!任何原因它只在高度本地做到这一点:33px; :

enter image description here& (小提琴风格)enter image description here

<div class="outerDiv">
    <div class="messages">
        <div class="topMessage">
            new message that is really long and should be on multiple lines as this continues on to the next line and so on and so forth
        </div>
    </div>
    <div class="comments">
        <div class="comment">Here's a comment</div>
    </div>
</div>

无论出于何种原因,设置最小高度:33px;不起作用,只有高度:33px; ..和自动换行或溢出-y:auto; (不太可取)根本不工作..

.outerDiv {
  width: 260px;
}
.messages {
  float: left;
  min-width: 100%;
  max-width: 100%;
  min-height: 33px;
  border: 1px solid #999;
  display: table;
  padding: 1%;
  font-size: 12.9px;
}
.topMessage {
  display: table-cell;
  vertical-align: middle;
  padding-left: 2%;
  font-size: 12.9px;
}
.comments {
  float: left;
  min-width: 100%;
  max-width: 100%;
  height: 33px;
  border: 1px solid #000;
  padding: 1%;
  display: table;
}
.comment {
  display: table-cell;
  vertical-align: middle;
  padding-left: 2%;
  padding-right: 2%;
  font-size: 12.9px;
}

1 个答案:

答案 0 :(得分:1)

正如@ChristianVarga所指出的那样:“你的本地副本上是否有行高:0?”

继承的行高:0;干扰的风格。