内联显示2个按钮

时间:2014-05-27 01:15:11

标签: html css

我已经看到这个问题在不同的帖子中得到了回答,但答案对我来说似乎没什么用,所以我想问一下。如何发布2个按钮,每个按钮提交2个不同的内联形式?我尝试在按钮上添加display:inline和inline-block,但它似乎无法正常工作。

这是我的代码:

echo "<div class = 'actCell'>";
    echo "<form id = ".$i." name='edit_company'  class='form-inline' enctype='multipart/form-data' action = '/DTS/index.php/Index/viewDocumentType' method = 'POST'>";
    echo "<input type = 'hidden' name = 'doc_type' value = '".$doc_type." '/>";
    echo "<input type = 'hidden' name = 'doc_id' value = '".$doc_id." '/>";
    echo "<button  onclick='document.getElementById(".$i.").submit()'/><span class = 'editBut' style = 'display: inline;'><img src =".base_url()."images/glyphicons_edit.png class = 'editImg'></span></button>";
    echo "</form>";
    //echo "<td><input type = 'submit' value = 'Edit'/></td>";
    echo "<form id = del".$i." name='delete_docType'  class='form-inline' enctype='multipart/form-data' action = '/DTS/index.php/delete_info/deleteInfoDocumentType' method = 'POST'>";
    echo "<input type = 'hidden' name = 'doc_type' value = '".$doc_type." '/>";
    echo "<input type = 'hidden' name = 'doc_id' value = '".$doc_id." '/>";
    echo "<button  onclick = 'return deleteRow(this)' /><span class = 'delBut' style = 'display: inline;'><img src =".base_url()."images/glyphicons_exclamation_mark.png class = 'delImg'></span></button>";
    echo "</form>";
    echo "</div>";
    echo "</div>";

CSS代码:

.editAction, .actCell{
text-align: left;
display: table-cell;
}

注意:这些按钮是表格的一部分,因此包含表格的div上的表格单元格显示。

1 个答案:

答案 0 :(得分:1)

重新排列HTML元素,并将按钮与表单(表单外)分开:

当您必须提及属性值时,它们应该在双引号内。所以使用单引号来回应php中的那些行

    echo '<div class = "actCell">';
        echo '<form id = "'.$i.'" name="edit_company"  class="form-inline" enctype="multipart/form-data" action = "/DTS/index.php/Index/viewDocumentType" method = "POST">';
        echo '<input type = "hidden" name = "doc_type" value = "'.$doc_type.'" />';
        echo '<input type = "hidden" name = "doc_id" value = "'.$doc_id.'" />';
        echo '</form>';
        //echo "<td><input type = 'submit' value = 'Edit'/></td>";
        echo '<form id = "del'.$i.'" name="delete_docType"  class="form-inline" enctype="multipart/form-data" action = "/DTS/index.php/delete_info/deleteInfoDocumentType" method = "POST">';
        echo '<input type = "hidden" name = "doc_type" value = "'.$doc_type.'" />';
        echo '<input type = "hidden" name = "doc_id" value = "'.$doc_id.'" />';
        echo '</form>';
    echo '<button  onclick="document.getElementById("'.$i.'").submit()"><span class = "editBut"><img src ="'.base_url().'images/glyphicons_edit.png" class = "editImg"></span></button>';
    echo '<button  onclick = "return deleteRow(this)" ><span class = "delBut" ><img src ="'.base_url().'images/glyphicons_exclamation_mark.png" class = "delImg"></span></button>';
        echo '</div>';
        echo '</div>';

set css to:

    button{ display: "block"; float: "left"; }

在最后一个按钮后添加额外的div标签:

    echo '<div style="clear:both;"></div>';

注意:默认情况下,span元素显示为内联。因此,如果你之前没有改变它,你就不要把css显示为内联。