javascript - Angular Js 弹出菜单

标签 javascript css angularjs

这是我在 Angular js 中的第一个元素,我试图在弹出菜单中显示一棵树。我找到了这个下拉菜单示例 http://angular-ui-tree.github.io/website/tree.html我想将其更改为弹出菜单。

因此在给定的示例中,子节点显示在父节点下方。但是,我希望子节点显示在父节点的右侧。

有没有我遗漏的例子? 知道菜单内容将动态加载的最佳方法是什么?

最佳答案

这是一个使用 Angular 的简单弹出菜单。示例中的内容不是动态的,但可以调整数据模型,以便动态加载菜单的内容。

http://codepen.io/jonnycincocinco/pen/dpovAB

.tree {
  position: relative;
  display: block;
  width: 150px; }
  .tree .currentItem {
    position: relative;
    display: inline-block;
    box-sizing: border-box;
    width: 150px;
    padding-left: 10px;
    cursor: pointer;
    min-height: 30px;
    line-height: 30px;
    border: 1px solid #d8d8d8;
    border-radius: 3px; }
    .tree .currentItem:hover {
      background-color: #f9f9f9; }
    .tree .currentItem > .arrow {
      top: 13px; }
    .tree .currentItem > ul {
      left: -1px;
      top: -5px; }
  .tree li a {
    display: block;
    position: relative;
    min-height: 30px;
    line-height: 30px;
    padding-left: 10px;
    padding-right: 20px;
    cursor: pointer;
    color: #7f7f7f;
    text-decoration: none; }
  .tree .arrow {
    position: absolute;
    top: 10px;
    right: 10px; }
    .tree .arrow.right {
      border-left-color: #7f7f7f; }
  .tree li a.active {
    background: #4285f4;
    color: white; }
    .tree li a.active > .arrow.right {
      border-left-color: white; }
  .tree ul {
    box-sizing: border-box;
    width: 150px;
    padding: 10px 0;
    top: -11px;
    left: 100%;
    display: none;
    position: absolute;
    background: white;
    border-radius: 3px;
    border: 1px solid #d8d8d8;
    box-shadow: 0 5px 10px 0 rgba(0, 0, 0, 0.2); }
  .tree .active > ul {
    display: block; }

关于javascript - Angular Js 弹出菜单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36703387/

相关文章:

css - 不需要的滚动条

css - 右边距浏览器

javascript - 访问其他 Controller 中的localStorage变量数据

javascript - 使用 AngularJS 中的表单对 ControllerAs 进行单元测试

javascript - 将 R.filter 和 R.map 重构为 Pointfree 风格的 R.reduce

javascript - 刷新另一个页面

javascript - 如何使用html表单将数据发送到javascript以保存为变量

javascript - 将 for 循环中的值传递给事件监听器 - Javascript

javascript - 如何将javascript变量传递给php以存储在wordpress的数据库中?

javascript - AngularJS - 带插值的动态标题