0

如何将按钮与文本“Nulla vitae quam a velit dictum tincidunt. Maecenas...”放在同一行?

我正在使用这个

style="overflow: hidden; text-overflow: ellipsis; white-space: nowrap;"

所以该行以面板大小结束。没有它,如果文本不够大,按钮和文本将保持在同一行。

http://jsfiddle.net/Khrys/4PHAE/

<div class="col-md-4">
    <div class="panel panel-default">
        <div class="panel-heading" style="overflow: hidden; text-overflow: ellipsis; white-space: nowrap;">
            <span>Nulla vitae quam a velit dictum tincidunt. Maecenas sed dapibus nunc.</span>
            <div class="btn-toolbar pull-right">
                <div class="btn-group">
                    <a href="#" class="btn btn-default btn-xs">?</a>
                    <a href="#" class="btn btn-default btn-xs">!</a>
                </div>
            </div>
        </div>
        <div class="panel-body text-center">
            <p class="lead" style="margin-bottom: 0px;">Description</p>
        </div>
        <div class="panel-footer" style="overflow: hidden; text-overflow: ellipsis; white-space: nowrap;"><small>Iten #1, Iten #2, Iten #3, Iten #4, Iten #5, Iten #6, Iten #7, </small></div>
    </div>
</div>
4

1 回答 1

4

您可以将按钮放在外部,.panel-heading因为它是强制的元素,overflow:hidden然后为您的按钮和具有固定宽度的文本 div赋予float或属性。display:inline-block

HTML

<div class="panel panel-default">
    <div class="panel-heading" style="overflow: hidden; text-overflow: ellipsis; white-space: nowrap;">
        <span>Nulla vitae quam a velit dictum tincidunt. Maecenas sed dapibus nunc.</span>
    </div>
    <div class="btn-toolbar pull-right">
        <div class="btn-group">
            <a href="#" class="btn btn-default btn-xs">?</a>
            <a href="#" class="btn btn-default btn-xs">!</a>
        </div>
    </div>
</div>

CSS

.panel {
  position:relative;
  width:200px;
}
.panel-heading {
  max-width:150px;
  float:left;
}
.btn-toolbar {
  width:50px;
  float:right;
}

查看此演示http://jsfiddle.net/6ZpBL/2/

于 2013-10-30T12:30:52.520 回答