用php foreach语句写动态网站排版商品界面,图片超出网页设置本身大小
<div
style="width: 200px; height: 300px; background-color: #DCDCDC; display: table-cell;">
<img style="width: 200px; height: 200px"
src=" echo $v['Product_image_path']; ?>" >
<div
style="width: 100%; height: 100px; background-color: #F6F6F6; text-align: center;">
<div style="height: 5px;">div>
<div>
<label style="font-size: 20px"> echo $v['Product_name']; ?>label>
div>
<div style="margin-top: 1px">
<label style="color: #696969"> echo $v['Price']; ?>label>
div>
<div style="margin-top: 1px">
<button class="fileinput-button" >Know morebutton>
div>
div>
div>
endforeach; ?>
div>
显示是图片排列一行到底,然后超出设置页面
试过修改格式,但是失败了
按照一行五个向下排列,固定一行五个,但是列可以无限向下排列
flex布局就可以了呀
display: flex;
flex-wrap: wrap;
参考一下
看来是同样的问题,不知道是不是同样的人。
主要是html布局,php返回数据即可。
你试试看看html与php结合,然后也了解下html中的flex布局方式。
自适应宽代码示例:
.container{
display: flex;
}
/**左侧定宽高,右侧设置自适应的元素**/
.right {
flex: 1;
}
我一般使用flex布局 超出的部分让他自动换行
display: flex;
flex-wrap: wrap;
可以使用flex布局,在超过一行时,换行显示
这个说难不难,如果不是纯前端技术人员 没必要自己一点点写css,用bootstrap 这类的前端ui框架会省很多事,完全不用考虑这类兼容性问题
使用弹性盒子布局
display: flex; //把盒子在一行显示
overflow-x: hidden; //超出隐藏
flex-wrap: wrap; //超出自动换行
先是通过display:flex把所有的div整到一行中,overflow:hidden超出部分隐藏,flex-wrap:wrap超出自动换行
foreach 代码内容不全,看不到父级情况。