如何使<h2>和<button>出现在同一行上?

时间:2020-04-28 12:54:43

标签: twitter-bootstrap-3

在Bootstrap 3网页中,我有一个h2标头,然后有一个下拉按钮...

<h2>Employees</h2>
<div class="dropdown">
    <button class="btn btn-dark dropdown-toggle" type="button"
        data-toggle="dropdown">
        Config Menu <span class="caret"></span>
    </button>
    <ul class="dropdown-menu">
        <li><a href="#"  onclick="openAddNewEmployee()">Add New Employee ...</a></li>
    </ul>
</div>

下拉菜单显示在h2的下一行。

如何使下拉菜单显示在h2的右侧而不是下一行的上方?

1 个答案:

答案 0 :(得分:0)

找到了另一个已回答的问题,它有帮助:How to write both h1 and h2 in the same line?

最后,这是我的解决方法...

<h2 style="text-align:left;float:left;padding-right:25px">Employees</h2>
<div class="dropdown"style="text-align:left;float:left;margin-top:20px">
    <button class="btn btn-dark dropdown-toggle" type="button"
        data-toggle="dropdown">
        Config Menu <span class="caret"></span>
    </button>
    <ul class="dropdown-menu">
        <li><a href="#"  onclick="openAddNewEmployee()">Add New Employee ...</a></li>
    </ul>
</div>
<hr style="clear:both;"/>
相关问题