【问题标题】:Horizontal movable menu with a click单击即可水平移动菜单
【发布时间】:2013-06-30 02:24:25
【问题描述】:

http://i.stack.imgur.com/VPqxq.png

这就是我想要实现的,通过单击右箭头,它应该加载剩余的菜单项,并且与左箭头相同但向左。

我正在使用 asp.net!但是我可以通过 css 和 J Query 或 java 脚本来实现吗?谁能指出使用这个的网站?

【问题讨论】:

  • 您需要包含一些示例代码的链接。

标签: javascript jquery asp.net css


【解决方案1】:

这是一个 JS Fiddle,应该可以帮助您尝试构建。

一个左右动画的导航菜单。

http://jsfiddle.net/bYY39/

HTML

<div class='navigation'>
    <button type='button' class="left-arrow"><p><</p></button>
    <ul>
        <li class='item1'><a href="#">menu item1</a></li>
        <li><a href="#">menu item2</a></li>
        <li><a href="#">menu item3</a></li>
        <li><a href="#">menu item4</a></li>
        <li><a href="#">menu item5</a></li>
        <li><a href="#">menu item6</a></li>
    </ul>
    <button type='button' class='right-arrow'><p>></p></button>
</div>

CSS

* {
    margin: 0px;
    padding: 0px;
}

button {
    border:none;
    cursor: pointer;
}

.navigation {
    width: 1000px;
}

.left-arrow {
    background: #3d69b9;
    float: left;
    height: 60px;
    text-align: center;
    width: 60px;
}

.left-arrow:hover {
    background: #69c;
}

.left-arrow p {
    color: #fff;
    font-size: 18px;
}

.right-arrow {
    background: #3d69b9;
    border-left: 1px solid #69c;
    float: left;
    height: 60px;
    text-align: center;
    width: 60px;
}

.right-arrow:hover {
    background: #69c;
}

.right-arrow p {
    color: #fff;
    font-size: 18px;
}

ul {
    float:left;
    font-size: 0;
    overflow: hidden;
    width: 815px;
    white-space: nowrap;
}

li {
    border-left: 1px solid #69c;
    color: #fff;
    display: inline-block;
    font-size: 16px;
    height: 60px;
    list-style: none;
    text-align: center;
    width: 162px;
}

li a {
    background: #3d69b9;
    color: #fff;
    display: block;
    height: 100%;
    padding-top: 18px;
    text-decoration: none;
    width: 100%
}

li a:hover {
    background: #69c;
}

JS

$('.left-arrow').on({click: function() {
        $('.item1').animate({marginLeft:'0px'}, 500);
    }
});

$('.right-arrow').on({click: function() {
        $('.item1').animate({marginLeft:'-163px'}, 500);
    }
});

【讨论】:

  • 这正在工作@djrconcepts,但在 IE 中一切都出错了。特别是当我在 js 中增加内容和 marginLeft 时,它只会移动下一个 li 元素!而在 css 中溢出:隐藏;可能无法在 IE 中工作! IE 10
  • 我使用 来解决这个问题。
猜你喜欢
  • 2014-09-23
  • 2015-12-29
  • 1970-01-01
  • 1970-01-01
  • 2020-12-06
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多