nerburish/yii2-masonry-view
最新稳定版本:1.0.0
Composer 安装命令:
composer require nerburish/yii2-masonry-view
包简介
ListView widget improved to use Masonry (http://masonry.desandro.com/)
README 文档
README
Yii2 widget to extend the Yii2 ListView for use it as Masonry grid layout (http://masonry.desandro.com/)
Installation
The preferred way to install this extension is through composer.
Either run
php composer.phar require --prefer-dist nerburish/yii2-masonry-view "*"
or add
"nerburish/yii2-masonry-view": "*"
to the require section of your composer.json file.
Usage
The usage is similar to default ListView Widget (http://www.yiiframework.com/doc-2.0/yii-widgets-listview.html)
You just need a dataProvider and prepare the item template for your model.
In clientOptions you can pass the Masonry options to modify the plugin behavior (see http://masonry.desandro.com/options.html)
You can also attach a cssFile for styling the grid.
Exemple
We have this model:
class MyModel extends \yii\base\Model
{
public $id;
public $title;
public $description;
}
And this item template named _item.php:
<h3><?= $model->title ?></h3>
<p><?= $model->description ?></p>
Finally, in our view, we run the widget:
<?php echo \nerburish\masonryview\MasonryView::widget([
'dataProvider' => $dataProvider,
'itemView' => '_item',
'clientOptions' => [
'gutterWidth' => 15,
],
'cssFile' => [
"@web/css/masonry-demo.css"
]
]) ?>
Below, the css used for the demo:
/* ---- grid ---- */
.grid {
box-sizing: border-box;
}
/* clearfix */
.grid:after {
content: '';
display: block;
clear: both;
}
/* ---- grid-item ---- */
.grid-item {
width: 20%;
padding: 10px;
margin: 10px auto;
float: left;
background: #e4e4e4;
border-radius: 5px;
}
You may be interested in Isotope Widget because implements Masonry and other layouts and funcionalities at once. https://github.com/nerburish/yii2-isotope-view
There is also a MatchHeight.js implementation of ListView widget: https://github.com/nerburish/yii2-match-height-view
统计信息
- 总下载量: 1.55k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 6
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-08-22
