html - Wordpress Metabox 输入表单溢出

标签 html css wordpress

我有一个带有一些表格和输入表单的 Wordpress 插件。这些表是使用标准的 Wordpress 表 widefat 类构建的。输入表单嵌入到 widefat 表的单元格中。

在我刚刚显示数据的地方,表格会调整大小以适合元数据框。在我使用输入字段的地方,表格溢出了元数据框,见图:

Input forms overrunning WordpressMetabox

我希望输入表像数据表一样调整大小。

这是普通表格的呈现方式:

<table class="widefat" id="item_publication_attributes">
    <tr>
        <th class="type"><b>Type</b></th>
        <th class="date"><b>Date</b></th>
        <th class="name"><b>Name</b></th>
        <th class="address"><b>Address</b></th>
        <th class="gender"><b>Map</b></th>
        <th></th>
    </tr>
    <tr class="publish-attribute publish-attribute-1">
        <td class="type">Publisher</td>
        <td class="date">15/2/1971</td>
        <td class="name">Publish Company</td>
        <td class="location">63 The Street, The Town, Cambridgeshire</td>
        <td class="map-icon" style="font-size:70%">[map]</td>
        <td><a href="#" class="publish-attribute-delete" data-id="1">Delete</a> | <a href="#" class="person-edit" data-id="1">Edit</a></td>
    </tr>
</table>

这就是 Form 表的呈现方式:

<form>
<input type="hidden" name="post_id" id="add_publishing_attribute_post_id" value=2624/>
<table class="widefat" id="add_new_publishing_attribute">
    <tr id="add_new_publishing_attribute_row">
        <td class="type">
            <select name="type" id="add_attribute_type">
                <option value="0">ID 0</option>
                <option value="1">ID 1</option>
                <option value="2">ID 2</option>
            </select>
        </td>
        <td class="dd"><input type="text" name="dd" id="add_attribute_dd" placeholder="dd" /></td>
        <td class="mm"><input type="text" name="mm" id="add_attribute_mm" placeholder="mm" /></td>
        <td class="yyyy"><input type="text" name="yyyy" id="add_attribute_yyyy" placeholder="yyyy" /></td>
        <td class="name"><input type="text" name="name" id="add_attribute_name" placeholder="name" /></td>
        <td class="location"><input type="text" name="location" id="add_attribute_location" placeholder="location" /></td>          
        <td><input type="submit" name="submit" id="add_new_attribute_submit" value="Add"/></td>
    </tr>
</table>
</form>

感谢任何建议

最佳答案

我不明白的是为什么您要在元框内使用表单...我们只需将输入字段放在那里,save_post 会处理其余部分,here's a full example

要修复表格布局,我在这里找到了答案:Why is my HTML table not respecting my CSS column width?

使用:table-layout:fixed:

<table class="widefat" id="add_new_publishing_attribute" style="table-layout:fixed">

关于html - Wordpress Metabox 输入表单溢出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19546501/

相关文章:

javascript - axios 调用从第一个 api 获取响应并传递到第二个 api

javascript - div 里面的 div,搞砸了

php - 使用 mysql 中保存的数据填充表单

html - 自定义 Bootstrap 嵌套列对齐

wordpress - 在 Localhost 中更改站点 URL 和 WordPress URL

php - 在 Woocommerce 3+ 中检查产品价格是否含税

JavaScript 无法显示数组中的图像

javascript - 替换jquery html对象中的类

html - html 形式的 Font Awesome 图标

css - Flexbox 在 Safari 上没有按预期换行。我究竟做错了什么?