Typoscript为每两列渲染css bootstrap图像列clearfix?

时间:2014-08-01 21:54:45

标签: html twitter-bootstrap typo3 typoscript typo3-6.2.x

所以我有一些元素有6个图像列,每个图像上都有标题。有些字幕比其他字幕更大,因此在移动设备上没有很好地显示行数。

Bootstrap有此选项可以仅清除所需的视口:

<div class="row">

    <div class="col-xs-6 col-sm-2">.col-xs-6 .col-sm-2</div>
    <div class="col-xs-6 col-sm-2">.col-xs-6 .col-sm-2</div>

    <!-- Add the extra clearfix for only the required viewport -->
    <div class="clearfix visible-xs-block"></div>

    <div class="col-xs-6 col-sm-2">.col-xs-6 .col-sm-2</div>
    <div class="col-xs-6 col-sm-2">.col-xs-6 .col-sm-2</div>

    <!-- Add the extra clearfix for only the required viewport -->
    <div class="clearfix visible-xs-block"></div>

    <div class="col-xs-6 col-sm-2">.col-xs-6 .col-sm-2</div>
    <div class="col-xs-6 col-sm-2">.col-xs-6 .col-sm-2</div>
</div>

如果我可以使用typoscript打印HTML,那将是完美的。

typoscript我已经为列添加了正确的类,但我不知道如何打印每两列而不是最后一列。

我的错别字:

addClassesCol.ifEmpty = 
addClassesCol.override.cObject = COA
addClassesCol.override.cObject {
    10 = CASE
    10 {
        key.field = imagecols

        default = TEXT
        default.value = col-md-12

        2 < .default
        2.value = col-sm-6 

        3 < .default
        3.value = col-sm-4 col-xs-6

        4 < .default
        4.value = col-sm-3 col-xs-6

        6 < .default
        6.value = col-sm-2 col-xs-6
    }
}

我可以用来创建它的任何例子吗?

1 个答案:

答案 0 :(得分:0)

如果每行有3列,请将clear:都应用于每个第三项。

给出这样的HTML,

.row.apps
  .col-xs-6.col-sm-4.app-container
    .app

应用此CSS

.app-container:nth-child(2n+1) {
  clear: both;
}

@media only screen and (min-width: $screen-sm){
  .app-container:nth-child(3n+1) {
    clear: both;
  }
}

Here you can find more details on my site and article.