【问题标题】:Two semantic sidebars in "layers" on a page?页面上“层”中的两个语义侧边栏?
【发布时间】:2018-09-17 00:30:33
【问题描述】:

环境:Electron 桌面单页应用

我有一个项目,我想使用两个Semantic UI 侧边栏方案。一次只能看到一个方案。我已经看过这个较早的问题( Semantic-UI: Two Sidebars Conflict, Only One at a Time? ) 但它只回答了我的部分问题。

做一个简单的测试,将每个侧边栏方案包装在 div 中,我收到了一些 Semantic UI 警告(“必须移动侧边栏。为了获得最佳性能,请确保侧边栏和推送器是您的直接子项身体标签”)。在我走得更远之前,谁能告诉我下面的结构是否可行,或者是否有其他推荐的方法来解决这个问题?

我将根据用户交互显示/隐藏这些“层”——两个层都需要语义侧边栏功能。


  <body>
  <div id="LAYER-1" class="ui sidebar inverted vertical menu">
    <!-- ************** Sidebar content ************* !-->
  </div>    
  <div class="pusher">
    <!-- ************** Layer content ************* !-->
  </div>

  <div id="LAYER-2" class="ui sidebar inverted vertical menu">
    <!-- ************** Sidebar content ************* !-->
  </div>    
  <div class="pusher">
    <!-- ************** Layer content ************* !-->
  </div>
  </body>

【问题讨论】:

    标签: javascript semantic-ui


    【解决方案1】:

    我可以通过为Semantic 侧边栏设置context 来解决这个问题。这个答案 (Semantic-ui - how to use sidebar in only part of a page? (ie with context)) 有助于阐明如何在 Semantic 文档中指定 contextexample 更好

    所以我最终得到的结果是:将每个“侧边栏集”包装在一个带有 ID 的 div 中,然后将该 div 指定为context。 “层” div 具有显示/隐藏最顶层的按钮。没有收到任何关于设置的Semantic 警告。


    JS

    $('#briefcaseExample .ui.sidebar')
            .sidebar({
                context: $('#briefcaseExample')
            })
            .sidebar('setting', 'transition', 'push')
    
    
    $('#timelineExample .ui.sidebar')
            .sidebar({
                context: $('#timelineExample')
            })
            .sidebar('setting', 'transition', 'push')
    

    HTML

    <body onload="onLoadApp()">
    
        <div id="briefcaseExample">
            <div class="ui sidebar inverted vertical menu">
                <!-- ************** Sidebar content ************* !-->
                <div id="sidebarTree" style="height: 100%;"></div>
            </div>
            <!-- ************** End Sidebar content ************* !-->
    
            <div class="pusher">
                <!-- ************** Site content ************* !-->
                <div id="solidBlue"></div>
                <div id="container" width="100%" height="100%">
                    <canvas id="c" width="100%" height="100%"></canvas>
                </div>
    
                <div class="briefcaseSidebarToggle">
                    <i class="big sidebar icon grey" onclick="toggleMenu()"></i>
                </div>
    
                <div class="briefcaseClose">
                    <i class="big remove circle icon grey" onclick="hideBriefcase()"></i>
                </div>
                <!-- ************** End Site content ************* !-->
            </div>
        </div>
    
        <div id="timelineExample">
            <div class="ui sidebar inverted vertical menu">
                <!-- ************** Sidebar content ************* !-->
                <div id="timelineSidebar" style="height: 100%;"></div>
            </div>
            <!-- ************** End Sidebar content ************* !-->
    
            <div class="pusher">
                <!-- ************** Site content ************* !-->
                <div class="timelineSidebarToggle">
                    <i class="big sidebar icon grey" onclick="toggleTimelineMenu()"></i>
                </div>
    
                <!-- ************** End Site content ************* !-->
    
                <div id="solidColor">
                    <button onclick="showBriefcase()">Show Briefcase</button>
                </div>
            </div>
        </div>
    </body>
    

    【讨论】:

      猜你喜欢
      • 2020-06-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-02-20
      相关资源
      最近更新 更多