Yii2 - DetailView小部件float left [英] Yii2 - DetailView widget float left

查看:312
本文介绍了Yii2 - DetailView小部件float left的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问候,



我试图通过应用新的CSS类来覆盖DetailView小部件的处理,运气。我想要一个DetailView小部件的几个实例中显示的所有记录并排显示。我在app\web\css中创建一个名为detail1-view的类,并将其应用于vendor文件夹中的detaiview.php。



我的详细视图是: / strong>

 <?= DetailView :: widget([
'model'=> $ model,
'attributes'=> [
//'titulo',
'noticia',
// cria um array com a fotografia,em que carrega a path no campo fieldName da bd
[
'attribute'=>'fotodir',
'value'=> $ model-> fotodir,
'format'=> image',['width'=>'230','height'=>'200']],
],
],
]

和我的detailview.php文件夹vendor / yiisoft / yii2 / widgets / ...在正确的位置有detail1视图类:

  public $ options = ['class' > 'detail1-view']; 

我的CSS

  .detail1-view {
display:inline-block;
width:30%;
border:1px solid#000;

}





任何人都有此问题的解决方案?



很感谢

解决方案



诀窍是创建另一个类:position:relative;

pre> < div class =detail-disposal>
<?= DetailView :: widget([
'model'=> $ model,
'options'=> ['class'=>'detail1-view'] ,
'attributes'=> [
//'titulo',
'noticia',
// cria um array com一个fotografia,em que carrega一个路径no campo fieldName da bd
[
'attribute'=>'fotodir',
'value'=> $ model-> fotodir,
'format'=> 'image',['width'=>'230','height'=>'200'],
],
],
]



app / web / css中使用的样式:

  .detail-disposal {
position:relative;
width:100%;

}



.detail1-view {

  margin-left:20px; 
margin-bottom:20px;
float:left;
width:300px;
border:1px solid#000;



}



detailview小部件在每次调用模型时并排显示。


Greetings,

i'm trying to override the disposal of the DetailView widget by applying new css class but with no luck. I want all the records shown in the several instances of a DetailView widget to appear side by side. I create a class in app\web\css called detail1-view and apply it to the detaiview.php in vendor folder. The class has float:left, or display:inline-block in it, but none of the attributes work.

My Detailview is:

<?= DetailView::widget([
    'model' => $model,
    'attributes' => [
      //'titulo',
      'noticia',
        // cria um array com a fotografia, em que carrega a path no campo fieldName da bd
        [
        'attribute'=>'fotodir',
        'value'=>$model->fotodir,
        'format' => ['image',['width'=>'230','height'=>'200']],
        ],
    ],
]) ?>

and my detailview.php in folder vendor/yiisoft/yii2/widgets/... has in it the detail1-view class in the right place:

public $options = ['class' => 'detail1-view'];

My CSS:

.detail1-view {
display: inline-block;
width: 30%; 
border:1px solid #000;

}

The DetailView continues to display one in top of another and not side by side

Anybody has a solution for this issue ?

Many Thanks

解决方案

I solved it by myself.

The trick was to create another class with position:relative; and put the detailview widget inside it.

Here's the code for the view:

<div class="detail-disposal">
<?= DetailView::widget([
    'model' => $model,
    'options' => ['class' => 'detail1-view'],
    'attributes' => [
      //'titulo',
      'noticia',
        // cria um array com a fotografia, em que carrega a path no campo fieldName da bd
        [
        'attribute'=>'fotodir',
        'value'=>$model->fotodir,
        'format' => ['image',['width'=>'230','height'=>'200']],
        ],
    ],
]) ?>

and the css style used in app/web/css:

.detail-disposal{
position:relative;
width:100%;

}

.detail1-view {

margin-left:20px;
margin-bottom:20px;
float:left;
width: 300px; 
border:1px solid #000;

}

Now the detailview widget appears side by side every time a model is called.

这篇关于Yii2 - DetailView小部件float left的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆