javascript - 是否可以在视觉上水平而不是垂直显示行?
问题描述
我想显示一组彼此相邻的图像
<table id="datatable" class="table table-colored table-info">
<thead>
<tr >
<th>Product_Name</th>
<th>Image</th>
</tr>
</thead>
<tbody>
<?php while ($players_list=m ysqli_fetch_array($players_fun)) { ?>
<tr>
<td>
<?php echo $players_list[ 'product_name']; ?>
</td>
<td>
<div class="col-sm-4">
<img src=" <?php echo $players_list[ 'product_IMAGE']; ?>" >
</div>
</td>
</tr>
<?php }?>
</tbody>
</table>
这是我的桌子,我可以在每行显示 3-3 张图片吗?
其实我想利用数据表的搜索和排序功能..
解决方案
您可以使用 css grid或flex来实现这一点。我尝试过使用 css 网格,请在此处找到
.img-vertical {
display: grid;
grid-template-columns: repeat(3, 1fr); // sets the horizontal layout
grid-gap: 1em;
place-content: center;
}
.img-vertical img {
max-width: 50px;
}
.img-horizontal {
grid-template-columns: repeat(1, 1fr); // sets vertically
}
或者,flex实现如下
.img-vertical {
display: flex;
align-items: center;
flex-flow: column; // sets vertically
}
.img-vertical img {
max-width: 50px;
}
.img-horizontal {
flex-flow: row; // sets the horizontal layout
}
推荐阅读
- firebase - 将 dart 文件卸载到云端并在 Flutter 中使用
- apache-kafka - ConcurrentKafkaListenerContainerFactory 是否增加了来自 Kafka 主题的消息消费的并行性
- amazon-web-services - GraphQL:无法写入增量同步记录
- python - 如何在pyqt5中设置QStandardItemModel的列宽
- javascript - Papaparse 未解析配置分隔符
- node.js - Electron + React + TypeScript + WebPack 桌面应用程序:找不到模块...“隧道代理”中的“tls”
- unity3d - 当我制作 The WebGl Link 时,它显示此错误 WebGL 构建在移动设备上不受支持。立方体赛跑者
- django - 我的表单没有保存使用引导程序在 django 中进行样式设置
- reactjs - 来自 useSelector 的数据导致无限重新渲染为依赖项
- python - 有没有办法在 O(1) 时间复杂度中删除 Python 中字符串的最后一个字符?