简体   繁体   English

努力使用语义UI边栏

[英]Struggling to use semantic UI sidebars

I'm new to semantic UI. 我是语义UI的新手。 I'm trying to create a simple sidebar with it but it doesn't seem to respond. 我正在尝试使用它创建一个简单的侧边栏,但它似乎没有响应。

Here's my code. 这是我的代码。

HTML HTML

<link rel="stylesheet" type="text/css" href="Semantic-UI/dist/semantic.min.css">
<link rel="stylesheet" type="text/css" href="Semantic-UI/dist/components/sidebar.min.css">

<script src="Semantic-UI/dist/semantic.min.js"></script>
<script src="jquery-3.1.1.js"></script>
<script src="Semantic-UI/dist/components/sidebar.min.js"></script>


<!-- LEFT MENU -->
<div class="ui left vertical inverted sidebar menu visible">
   <a class="item">1</a>
   <a class="item">2</a>
   <a class="item">3</a>
</div>

<!-- RIGHT MENU -->
<div class="ui right vertical inverted sidebar menu">
    <a class="item">1</a>
    <a class="item">2</a>
    <a class="item">3</a>
</div>

<div class="pusher">

    <div class="ui container">
        <!-- BODY -->
        <button id="left-sidebar-toggle">
         show sidebar
        </button>

        <button id="right-sidebar-toggle">
           show sidebar
        </button>
    </div>

 </div>

Javascript Java脚本

<script type="text/javascript">
  function main() {
    $('.ui.left.sidebar').sidebar({
        dimPage: false,
        transition: 'push',
        exclusive: false,
        closable: false
    });

    $('.ui.left.sidebar')
        .sidebar('attach events', '#left-sidebar-toggle');

    $('.ui.right.sidebar').sidebar({
        dimPage: false,
        transition: 'overlay',
        exclusive: false,
        closable: false
    });

    $('.ui.right.sidebar')
        .sidebar('attach events', '#right-sidebar-toggle');
}
 $(document).ready(main);
</script

I can't really tell what I'm doing wrong here. 我真的不能说出我在做什么错。 The code seems perfect. 该代码似乎很完美。 Any help would be appreciated. 任何帮助,将不胜感激。

Works in the code I have below. 在下面的代码中工作。 You have a naked script tag in your code and you haven't referenced your own JS file anywhere. 您的代码中有一个裸脚本标记,并且没有在任何地方引用您自己的JS文件。 I assume thats what the naked script tag was for. 我假设这就是裸脚本标签的用途。

 function main() { $('.ui.left.sidebar').sidebar({ dimPage: false, transition: 'push', exclusive: false, closable: false }); $('.ui.left.sidebar') .sidebar('attach events', '#left-sidebar-toggle'); $('.ui.right.sidebar').sidebar({ dimPage: false, transition: 'overlay', exclusive: false, closable: false }); $('.ui.right.sidebar') .sidebar('attach events', '#right-sidebar-toggle'); } $(document).ready(main); 
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.2.6/components/sidebar.js"></script> <link href="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.2.6/components/sidebar.css" rel="stylesheet"/> <div class="ui left vertical inverted sidebar menu visible"> <a class="item">1</a> <a class="item">2</a> <a class="item">3</a> </div> <!-- RIGHT MENU --> <div class="ui right vertical inverted sidebar menu"> <a class="item">1</a> <a class="item">2</a> <a class="item">3</a> </div> <div class="pusher"> <div class="ui container"> <!-- BODY --> <button id="left-sidebar-toggle"> show sidebar </button> <button id="right-sidebar-toggle"> show sidebar </button> </div> </div> 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM