如何在容器外部显示UIkit导航?

时间:2019-06-10 08:45:56

标签: html css html-lists getuikit

我想在其容器外部显示粘性UIkit导航。

在UIkit网站上有一个很好的例子。 https://getuikit.com/docs/introduction 忽略左侧的链接。

导航应该在内容的左侧(在示例中,它在右侧)

我还制作了此示例笔https://codepen.io/anon/pen/YoKxgB

<div class="uk-section">
    <div class="uk-container"></div>
</div>

https://i.ibb.co/nMhyz52/links.jpg

我非常感谢每个答案

1 个答案:

答案 0 :(得分:0)

在UIKit中,有一个名为sticky的函数专门用于此目的。只需使用具有偏移量的uk-sticky即可将其固定在此处(此处的偏移量是距顶部70)。

您可以在下面找到工作代码(从代码笔复制)

.admin-sidebar {
    position: absolute;
    width: 130px;
    left: -140px;
}
<!-- UIkit CSS -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/uikit/3.1.5/css/uikit.min.css" />

<!-- UIkit JS -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/uikit/3.1.5/js/uikit.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/uikit/3.1.5/js/uikit-icons.min.js"></script>

<div class="uk-section uk-section-default">
    <div class="uk-container" style="position: relative;">
        
       <div class="admin-sidebar uk-visible@xl">
          <!-- here we define uk-sticky with offset -->
          <div uk-sticky="offset:70">
            <ul class="uk-nav-default uk-nav-parent-icon" uk-nav>
                <li class="uk-nav-header">Navigation</li>
                <li><a href="#"><span class="uk-margin-small-right" uk-icon="icon: users"></span>Benutzer</a></li>
                <li><a href="#"><span class="uk-margin-small-right" uk-icon="icon: thumbnails"></span>Gruppen</a></li>
                <li><a href="#"><span class="uk-margin-small-right" uk-icon="icon: unlock"></span>Rechte</a></li>
                <li class="uk-nav-divider"></li>
                <li><a href=""><span class="uk-margin-small-right" uk-icon="icon: server"></span>Server</a></li>
             </ul>
          </div>
       </div>
      
        <div>
            <div class="uk-panel uk-margin-medium">
                <h3>UIkit</h3>
            </div>
            <div class="uk-card uk-card-default uk-card-body">
                <p>Content #1<br/>Lorem ipsum dolor sit amet, consectetur adipisicing elit.</p>
            </div>
            <div class="uk-card uk-card-default uk-card-body">
                <p>Content #2<br/>Lorem ipsum dolor sit amet, consectetur adipisicing elit.</p>
            </div>
            <div class="uk-card uk-card-default uk-card-body">
                <p>Content #2<br/>Lorem ipsum dolor sit amet, consectetur adipisicing elit.</p>
            </div>
            <div class="uk-card uk-card-default uk-card-body">
                <p>Content #2<br/>Lorem ipsum dolor sit amet, consectetur adipisicing elit.</p>
            </div>
        </div>

    </div>
</div>