css - 创建产品库
问题描述
该图像来自一个 laravel 控制器作为一个集合并被分块。所以基本上我知道如何对图像进行分块,我想我应该将这些块进一步分块,这就是我的问题所在。我该怎么做或最好的方法是什么,有没有人可以告诉我如何或在哪里可以学习做到这一点。
到目前为止,我已经尝试过分块引导网格系统,但这只是根据图像数量生成行和列。这是我使用块加引导程序的尝试
@foreach ($images->chunk(4) as $key=>$image)
<div class="row">
@foreach ($image as $item)
@if ($key===0)
<div class="col-md-3">
<div>
<span class="image-block block2">
<a class="image-zoom" href="{{ asset('uploads/property/large/'.$item->path) }}" rel="prettyPhoto[gallery]">
<img src="{{ asset('uploads/property/small/'.$item->path) }}" class="img-responsive" alt="CEC Gallery"></a>
</span>
</div>
</div>
@else
<div class="col-md-4">
<div>
<span class="image-block block2">
<a class="image-zoom" href="{{ asset('uploads/property/large/'.$item->path) }}" rel="prettyPhoto[gallery]">
<img src="{{ asset('uploads/property/small/'.$item->path) }}" class="img-responsive" alt="CEC Gallery"></a>
</span>
</div>
</div>
@endif
@endforeach
</div>
@endforeach
解决方案
您可以简单地使用 CSS Flex来实现这一点。
您可以像这样遍历图像:
<div class="gallery">
@foreach ($image as $item)
<div class="gallery__item">
<a class="image-zoom" href="{{ asset('uploads/property/large/'.$item->path) }}" rel="prettyPhoto[gallery]">
<img src="{{ asset('uploads/property/small/'.$item->path) }}" class="img-responsive" alt="CEC Gallery">
</a>
</div>
@endforeach
</div>
.gallery {
display: flex;
align-items: start;
justify-content: left;
flex-direction: row;
flex-wrap: wrap;
}
.gallery__item {
background-color: #ccc;
width: 50%;
flex-basis: 50%;
max-width: 50%;
min-height: 400px;
text-align: center;
line-height: 400px;
}
<div class="gallery">
<div class="gallery__item">1</div>
<div class="gallery__item">2</div>
<div class="gallery__item">3</div>
</div>
假设:
- 图像之间没有装订线。
推荐阅读
- python - Python SQLAlchemy 和 Postgres - 如何使用 json 值中的子字符串进行搜索
- ios - 首选语言和设备语言不匹配
- git - 使用 .gitignore 忽略我的项目中的 .env 文件
- javascript - 如何保护 JAMstack 应用程序中的(第 3 方)API 密钥?
- laravel - nuxt 和 laravel 是如何通信的?
- ios - 折叠时如何更改图像单元格?
- javascript - 无条件的循环 - Javascript
- tensorflow - 如何使用 Keras 运行单节点、多设备数据并行训练?
- python - 如何将带有gridfs的大型json文件直接导入mongodb并准备好模式
- vba - 查找任务,在开始和完成之间有特定日期