【问题标题】:how to change the result of this get function into two lines down?如何将此get函数的结果更改为两行?
【发布时间】:2018-01-22 13:13:10
【问题描述】:
function getotherResource(){
        $result = json_decode($this->curl->simple_get($this->API.'/otherResource'));
        $html = "";
        foreach($result as $r){
        $html.="<div class='m-b-xs m-t'>
        <label class='i-checks i-checks-md'>
            <input type='checkbox' name='chkotherResource' id='v-".$r->qEmployee."' value='".$r->employeeName."'>
            <i></i>
            ".$r->employeeName."
          </label>
        </div>";
        }
        echo $html;
    }

this my display how to change the look like this with the array?

【问题讨论】:

    标签: javascript php arrays web-services restful-url


    【解决方案1】:

    我会使用 css 来解决这个问题,特别是新的网格规范。我会将 foreach 包装在另一个 div.wrapper 中:

    function getotherResource(){
            $result = json_decode($this->curl->simple_get($this->API.'/otherResource'));
            $html = "***<div class='wrapper'>***";
            foreach($result as $r){
            $html.="<div class='m-b-xs m-t'>
            <label class='i-checks i-checks-md'>
                <input type='checkbox' name='chkotherResource' id='v-".$r->qEmployee."' value='".$r->employeeName."'>
                <i></i>
                ".$r->employeeName."
              </label>
            </div>";
            }
            ***$html.="</div>"***
            echo $html;
        }
    

    并添加以下css。

    .wrapper {
      display: grid;
      grid-gap: 10px;
      grid-template-columns: repeat(2, 50%);
    }
    

    【讨论】:

    • 我试过了,这不是我想要的,但非常感谢他的建议。
    • 那不是您想要的?如果订购不正确,我认为可以添加其他 css 以按您的意愿订购。但是,如果这不是解决方案,您能否提供一些说明?
    • 抱歉,我的帖子中有 2 张图片,您可以看到。图片 1 是根据我的语法显示的,我想更改图片 2?如果我使用你的 css,我的显示不会分成 2 列,只有 1 列向下,看起来更小。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-10-23
    • 2015-05-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多