页面末尾的菜单,但从上到下链接

时间:2016-08-15 11:07:49

标签: wordpress menu

我怎样才能做到这一点? 这是一个wordpress菜单。

pic

好的,到目前为止,我有这个:

ul{
    display: flex;

 li{
   width: 100%;

    a{
    position: absolute;
    bottom: 0;
    top: 0;
    width: 2%;

     span{
      display: block;
      position:absolute;
      top: 50%;
      transform: translateY(-50%);
      -webkit-transform: translateY(-50%);
      -moz-transform: translateY(-50%);
         };
     };
   };
};

并且它有效,但现在我需要某种javascript,因此跨度内的标题将居中,每个元素将从左右两侧具有相同的空间量。

pic2

完成后,添加左:%;到每个菜单项元素。

感谢您的帮助!

1 个答案:

答案 0 :(得分:0)

像这样: 小提琴:https://jsfiddle.net/uq3vLvpb/

html:

<ul>

       <li><a><span>one</span></a></li>

       <li><a><span>two</span></a></li>

       <li><a><span>three</span></a></li>

       <li><a><span>four</span></a></li>

       <li><a><span>five</span></a></li>

       <li><a><span>six</span></a></li>

       <li><a><span>seven</span></a></li>

       <li><a><span>eight</span></a></li>

    </ul>

css:

ul {
    li {
      width: 100%;
      a {
        position: absolute;
        bottom: 0;
        top: 0;
        width: 10.5%;
        font-family: 'Lora', serif;
        font-size: 26px;
        font-weight: 400;
        text-align: center;
        color: #ffffff;
        text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
        text-decoration: none;
        padding: 0 15px;
        cursor: pointer;
        span {
          display: block;
          position: absolute;
          top: 65%;
          left: 50%;
          transform: translate(-50%, -35%);
          -webkit-transform: translate(-50%, -35%);
          -moz-transform: translate(-50%, -35%);
        }
        &:hover {
          background-color: rgba(0, 0, 0, 0.4);
        }
      }
    }

    li:first-child {
      a {
        left: 9.5%;
      }
    }

    li:nth-child(2) {
      a {
        left: 19.5%;
      }
    }
    li:nth-child(3) {
      a {
        left: 29.6%;
      }
    }
    li:nth-child(4) {
      a {
        left: 39.6%;
      }
    }
    li:nth-child(5) {
      a {
        left: 49.7%;
      }
    }
    li:nth-child(6) {
      a {
        left: 59.8%;
      }
    }
    li:nth-child(7) {
      a {
        left: 69.9%;
      }
    }
    li:nth-child(8) {
      a {
        left: 80%;
       }
    }
  }
相关问题