How to display pictures in layui table:
Pictures need to use template.templet:
Note that the div cannot be omitted. 48px refers to the height of the div. If you want to determine the height of the img image, you need to design the style
<script type="text/javascript"> layui.use('table',function () { var table= layui.table; table.render({ elem:'#needstable' ,url:'{:url()}' ,method:'post' ,cellMinWidth:80 ,page:true ,cols:[[ {field:'needs_id',title:'id',fixed:'left',width:80} ,{field:'wx_username',title:'昵称',fixed:'left',width:80} ,{field:'wx_headimg',title:'头像',fixed:'left',templet:'<div><img src="{{ d.wx_headimg}}"></div>',style:'height:48px;width:48px;line-height:48px!important;'}
css separately. Pay attention to replacing the headimg
<style type="text/css">.layui-table-fixed-r td{height:58px!important;} .layui-table-fixed-r th{height:58px!important;} .layui-table img { max-width: 48px;min-height: 48px; } .laytable-cell-3-wx_headimg ,.laytable-cell-1-wx_headimg,.laytable-cell-2-wx_headimg,.laytable-cell-3-wx_headimg,.laytable-cell-4-wx_headimg,.laytable-cell-5-wx_headimg,.laytable-cell-6-wx_headimg,.laytable-cell-7-wx_headimg,.laytable-cell-8-wx_headimg,.laytable-cell-9-wx_headimg,.laytable-cell-10-wx_headimg,.laytable-cell-11-wx_headimg,.laytable-cell-12-wx_headimg,.laytable-cell-13-wx_headimg,.laytable-cell-14-wx_headimg{ width: 48px!important;;padding:0px!important;height: 48px!important;; line-height: 48px!important;; } </style>
recommended :layui framework tutorial
The above is the detailed content of How to display pictures in the list in layui. For more information, please follow other related articles on the PHP Chinese website!