data-uk-grid-margin属性在UIkit 2.x和3.0中不起作用

时间:2018-07-10 02:20:01

标签: uikit getuikit

我正在尝试使用UIkit创建元素网格  前端框架。问题是当我添加data-uk-grid-margin来设置元素之间的边距时,它没有任何改变。我不知道我的错误在哪里,但是我认为UIkit javascript文件丢失了我的代码。

这是我的代码段:

<html>
    <head>
        <title>Title</title>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <link rel="stylesheet" href="uikit-2.27.5/css/uikit.min.css" />
        <script src="uikit-2.27.5/js/uikit.min.js"></script>
        <script src="uikit-2.27.5/js/uikit.js"></script>
        <script src="uikit-2.27.5/js/uikit-icons.min.js"></script>
    </head>
    <body>
    <div class="uk-container">
      <ul class="uk-grid uk-align-center uk-margin" data-uk-grid-margin>
        <li class="uk-width-1-3">
          <div class="uk-panel uk-panel-box">
              <div class="uk-panel-badge uk-badge"></div>
              <h3 class="uk-panel-title">Title</h3>
              <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
            </div></li>
            <li class="uk-width-1-3">    <div class="uk-panel uk-panel-box">
                  <div class="uk-panel-badge uk-badge"></div>
                  <h3 class="uk-panel-title">Title</h3>
                  <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
                </div></li>
                <li class="uk-width-1-3">    <div class="uk-panel uk-panel-box">
                      <div class="uk-panel-badge uk-badge"></div>
                      <h3 class="uk-panel-title">Title</h3>
                      <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
                    </div></li>
                    <li class="uk-width-1-3">    <div class="uk-panel uk-panel-box">
                          <div class="uk-panel-badge uk-badge"></div>
                          <h3 class="uk-panel-title">Title</h3>
                          <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
                        </div></li>
      </ul>
    </div>
    </body>
</html>

此外,我正在为UIkit使用Atom插件来帮助我完成自动填充,但是 javascript属性的建议也被遗漏了。

1 个答案:

答案 0 :(得分:1)

确保您要拨打电话:

    首先是
  • jQuery (这里是2.1.1,因为SO代码段提供了它)
  • 只有一个Uikit javascript文件(最好是uikit.min.js)

下面的工作示例

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/uikit/2.27.5/css/uikit.min.css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/uikit/2.27.5/js/uikit.min.js"></script>

<div class="uk-container">
  <ul class="uk-grid uk-align-center uk-margin" data-uk-grid-margin>
    <li class="uk-width-1-3">
      <div class="uk-panel uk-panel-box">
        <div class="uk-panel-badge uk-badge"></div>
        <h3 class="uk-panel-title">Title</h3>
        <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
      </div>
    </li>
    <li class="uk-width-1-3">
      <div class="uk-panel uk-panel-box">
        <div class="uk-panel-badge uk-badge"></div>
        <h3 class="uk-panel-title">Title</h3>
        <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
      </div>
    </li>
    <li class="uk-width-1-3">
      <div class="uk-panel uk-panel-box">
        <div class="uk-panel-badge uk-badge"></div>
        <h3 class="uk-panel-title">Title</h3>
        <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua</p>
      </div>
    </li>
    <li class="uk-width-1-1">
      <div class="uk-panel uk-panel-box">
        <div class="uk-panel-badge uk-badge"></div>
        <h3 class="uk-panel-title">Title</h3>
        <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>
      </div>
    </li>
  </ul>
</div>