代码之家  ›  专栏  ›  技术社区  ›  TruMan1

重新创建Office Ribbon的“样式”下拉区域?

  •  1
  • TruMan1  · 技术社区  · 14 年前

    http://www.winsupersite.com/images/reviews/office2007_b2_06.jpg

    我喜欢它开始时只有一行,然后你可以滚动行,然后单击箭头将所有行展开到上面这样的表中。有没有人有任何想法,如何重建整个互动??

    1 回复  |  直到 14 年前
        1
  •  1
  •   Ben    14 年前

    CSS

    #container { width:200px;height:50px;overflow-x:hidden;overflow-y:auto;
                 border:1px solid black; position:relative }
    #expander { position:absolute;right:0;bottom:0px;font-size:10px;margin:0;padding:1;
                 border:1px solid black; border-width:1px 0 0 1px }
    .item { float:left; font-size:30px;height:40px;width:50px;
             margin:5px; background:gainsboro;text-align:center }
    

    HTML格式

    <div id='container'>
      <div class='item'>A</div>
      <div class='item'>B</div>
      <div class='item'>C</div>
      <div class='item'>D</div>
      <div class='item'>E</div>
      <div class='item'>F</div>
      <div class='item'>G</div>
      <div class='item'>H</div>
      <div class='item'>I</div>
      <div class='item'>J</div>
      <div class='item'>K</div>
    
      <button id='expander' onclick='expand()'>&#9650;</button>
    </div>
    

    function $(id) { return document.getElementById(id); }
    
    function expand() {
      $('container').style.overflow = "auto";
      $('container').style.height = "300px";
      $('container').style.width = "300px";
    }
    
    function contract() {
      $('container').style.overflow = "hidden";
      $('container').style.height = "50px";
      $('container').style.width = "200px";
    }
    

    …应该让你开始。有几个虫子你得弄清楚:

    • 何时打电话 contract()
    • 按钮随内容滚动(并消失)