首页 > 解决方案 > 带有按钮的 HTML 内联表单

问题描述

这是我的 HTML 代码:

<div class="text-right">
    <form method="post" action="create_car_type.html">
        <button type="submit" value=4 class="btn btn-danger ml-2 mr-3" title="Create a car type">
            Create a type
        </button>
    </form>
    <form method="post" action="delete_car_type.html">
        <button type="submit" value=3 class="btn btn-warning ml-2 mr-3">
            Delete a type
        </button>
    </form>
</div>

这两个按钮在表单内部,在 div 内部。它们在这个 div 中右对齐,但我想内联显示它们。它们当前的显示方式是一个位置高于另一个位置,这是我想要避免的。display: inline我应该在某处包含类似的东西吗?这应该去哪里?

标签: htmlcss

解决方案


添加样式=“显示:内联块;” 形成标签

<div class="text-right">
    <form method="post" action="create_car_type.html" style="display: inline-block;">
        <button type="submit" value=4 class="btn btn-danger ml-2 mr-3" title="Create a car type">
            Create a type
        </button>
    </form>
    <form method="post" action="delete_car_type.html" style="display: inline-block;">
        <button type="submit" value=3 class="btn btn-warning ml-2 mr-3">
            Delete a type
        </button>
    </form>
</div>

推荐阅读