如何在Materialize中向sidenav添加子菜单?

时间:2019-04-04 17:18:58

标签: html css materialize

如何将子菜单添加到以下sidenav中?

<ul class="sidenav sidenav-fixed" id="nav-mobile" style="width:250px">
  <li> <a href="#" class="brand-logo center">Text here</a></li>
  <li>
    <div class="divider"></div>
  </li>

  <li>
    <a onclick="load('home')"><i class="material-icons">home</i>Home</a>
  </li>

  <li><a onclick="load('intro')"><i class="material-icons">apps</i>Content Table</a></li>

</ul>

2 个答案:

答案 0 :(得分:2)

MaterializeCSS文档站点在sidenav内使用可折叠:

https://materializecss.com/collapsible.html

Collapsible是一个单独的组件,也需要初始化:

import pandas as pd


def get_significant_vars(lm):
    var_p_vals_df = pd.DataFrame(lm.pvalues)
    var_p_vals_df['vars'] = var_p_vals_df.index
    var_p_vals_df.colums = ['pvals', 'vars']
    # filter the column name where p value is less than 0.05
    return list(var_p_vals_df[var_p_vals_df.pvals <= 0.05]['vars'])

工作码笔:

https://codepen.io/doughballs/pen/RwPWVqy

从Materialize文档站点获取的实际标记是:

significant_vars = get_significant_vars( logit_model )
significant_vars

Error:C:\Users\dell\Anaconda3\lib\site-packages\ipykernel_launcher.py:4: UserWarning: Pandas doesn't allow columns to be created via a new attribute name - see https://pandas.pydata.org/pandas-docs/stable/indexing.html#attribute-access
  after removing the cwd from sys.path.
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-117-985ab2e4e2a1> in <module>
----> 1 significant_vars = get_significant_vars( logit_model )
      2 significant_vars

<ipython-input-116-ea9aca6d9445> in get_significant_vars(lm)
      4     var_p_vals_df.colums= ['pvals','vars']
      5     #filter the column name where p value is less than 0.05
----> 6     return list( var_p_vals_df[var_p_vals_df.pvals <= 0.05]['vars'])
      7 

~\Anaconda3\lib\site-packages\pandas\core\generic.py in __getattr__(self, name)
   5065             if self._info_axis._can_hold_identifiers_and_holds_name(name):
   5066                 return self[name]
-> 5067             return object.__getattribute__(self, name)
   5068 
   5069     def __setattr__(self, name, value):

AttributeError: 'DataFrame' object has no attribute 'pvals'

答案 1 :(得分:0)

您可以使用MaterializeCSS进行以下操作

<div id="slide-out" class="sidenav" style="transform: translateX(0%);">
   <ul class="collapsible">
    <li class="active">
      <div class="collapsible-header">
        <a href="#/groups/1" class="router-link-exact-active router-link-active">Group1</a>
      </div> <div class="collapsible-body" style="display: block;">
       <li><a href="#/courses/1" class="waves-effect">Course 1</a></li>
       <li><a href="#/courses/2" class="waves-effect">Course 2</a></li>
      </div>
    </li>
    <li class="">
     <div class="collapsible-header">
       <a href="#/groups/2" class="">केंद्रीय लोकसेवा  आयोग </a>
     </div> 
     <div class="collapsible-body" style="">
     </div>
    </li>
  </ul>
</div>