layui-table 多一列

使用layui-table时发现会出现如下情况,多一列


2019-11-30_103915.png

原因是 给每一列设置了宽度,加起来还达不到容器的宽度,就自动填充了。
解决办法 给某一列不设置宽度,让其自适应

//可以这样
<table class="layui-table" lay-data="{height:315, url:'/data/type', page:true, id:'test'}" lay-filter="test">
        <thead>
        <tr>
            <th lay-data="{field:'id', width:80, sort: true}">ID</th>
            <th lay-data="{field:'type_name', width:200}">分类名称</th>
            <th lay-data="{field:'type_comment', sort: true}">分类描述</th>
        </tr>
        </thead>
    </table>
//也可以这样
        table.render({
            id: "testReload"
            , elem: '#demo'
            , url: '/data/user'
            , where: {
                id: 0
            },
            cols: [
                [ //标题栏
                    {field: 'id', title: 'ID', width: 80, sort: true},
                    {field: 'name', title: '用户名', width: 120},
                    {field: 'phone', title: '电话号码', minWidth: 150, edit: 'text'},
                    {field: 'address', title: '地址', minWidth: 160, edit: 'text'},
                    {fixed: 'right', width: 165, align: 'center', align: 'center', title: '操作', toolbar: '#barDemo'}
                ]
            ]
            , skin: 'line' //表格风格
        });
//还可以这样
<table id="orderTab" class="layui-table" lay-filter="orderTab" hidden="hidden">
                            <colgroup>
                                <col width="100">
                                <col width="150">
                                <col width="150">
                                <col width="150">
                                <col width="150">
                                <col width="150">
                                <col>
                            </colgroup>
                            <thead>
                            <tr>
                                <th>ID</th>
                                <th>用户名</th>
                                <th>商品名称</th>
                                <th>商品数量</th>
                                <th>商品单价</th>
                                <th>小计</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody id="orderTabBody" >

                            </tbody>
                        </table>
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • HTML 5 HTML5概述 因特网上的信息是以网页的形式展示给用户的,因此网页是网络信息传递的载体。网页文件是用...
    阿啊阿吖丁阅读 4,853评论 0 0
  • CSS 是什么 css(Cascading Style Sheets),层叠样式表,选择器{属性:值;属性:值}h...
    崔敏嫣阅读 1,560评论 0 5
  • ======= SEO专用 table-cell 定高水平垂直居中 不定高水平垂直居中 单行定高水平垂直居中 单行...
    木白no1阅读 10,582评论 1 15
  • 选择qi:是表达式 标签选择器 类选择器 属性选择器 继承属性: color,font,text-align,li...
    love2013阅读 2,406评论 0 11
  • 我与公子啊 就像是隔着十里青山 千处深谷 万家灯火一般无果
    人可禾子阅读 144评论 0 1

友情链接更多精彩内容