English 中文(简体)
Jquery tabs Navigation dots to be place based on the high of the tabs
原标题:Jquery tabs navigation dots to be positioned based on the height of the tabs
  • 时间:2012-04-20 11:15:08
  •  标签:
  • jquery
  • tabs

我希望,你可以帮助我这样做。

航海tabmenunav有3个小口径,位于表层底层,我需要计算每个表层的高度,并将其置于底层。 目前,所有方面都处于绝对地位, does不好。

Demo: http://jsfiddle.net/QxgDr/24/

<><>Jquery

(function tabszIndex() {

$( ul.tabmenu > li > a ).each(function(e) {
    $("#tabmenunav").append("<a href= javascript:void(0);  class=  >&#8226;</a>");
});

$( ul.tabmenu > li > a ).click(function(e) {
    var selectedTabIndex = $(this).parent().attr( id ).substring(3); //parseInt(this.hash.substring(4));
    $( ul.tabmenu a ).removeClass( active );
    $(this).addClass( active );
    $( #tabmenunav a ).removeClass( active );
    $( #tabmenunav a ).eq($(this).parent().index()).addClass( active );
    var i = 0;
    $( .tabmenu li ).css( z-index , function(index) {
        var z = index < selectedTabIndex ? 1 : (index > selectedTabIndex ? --i : 0);
        return z
    });
    e.preventDefault();
});
$( #tabmenunav a ).click(function() {
    var idx = $(this).index();
    $( > a , $( ul.tabmenu > li ).eq(idx)).trigger( click );

})
var lastTabIndex = $( .tab ).length - 1;
$( .tab ).each(function(i) {
    if (i != lastTabIndex) {
        $(this).append("<a href= javascript:void(0)  class= next-tab mover >Next Tab &#187;</a>");
    }
    if (i != 0) {
        $(this).append("<a href= javascript:void(0)  class= prev-tab mover >&#171; Prev Tab</a>");
    }
});
var tabMenu = $( .tab );
$( .next-tab, .prev-tab ).click(function() {
    var newTabIndex = $(this).hasClass( next-tab ) ? 1 : -1;
    var idx = (parseInt($(this).parents( li ).attr( id ).substring(3)) + newTabIndex);
    $( ul.tabmenu > li#tab  + idx +   > a ).trigger( click );
});
$( > a , $( ul.tabmenu > li ).eq(0)).trigger( click );

(iii)

最佳回答

引人注意的是,使用<代码>offset()http://api.jquery.com/offset/#offset2” rel=“nofollow”>Documentation。 你们可以利用这来抓住一个要素的位置,然后转而使用,确定另一个要素的位置。 我已利用这一技术修改了

这里我补充说:

var offsetGoal = $("#Overview").offset();
$("#Features").offset({ top: offsetGoal.top, left: (offsetGoal.left+100) });
$("#Technical").offset({ top: offsetGoal.top, left: (offsetGoal.left+200) });

也许这将为你工作。

www.un.org/Depts/DGACM/index_french.htm 我来到这里是为了调整你可能认为有用的立场。

我决定计算你在菜单中拥有的利要素数目(假设你最终会有更多的),并将之乘以一组子,以进行调整。

// However many elements in our tab menu should reinforce how far down to shift the navigation elements.
var shiftDotsBy = $(".tabmenu>li").size() * 3;
// Find the current position and just shift it downward
var dotsCurrentPos = $("#tabmenunav").offset();
$("#tabmenunav").offset({top: (dotsCurrentPos.top+shiftDotsBy), left: dotsCurrentPos.left});

http://jsfiddle.net/QxgDr/26/“rel=“nofollow”>Working example

jsfiddle经过更新,根据表格点击和相对高度差异,将狗转作。 这里的做法是:

// tab index is one-based; assuming each tab is twenty pixels lower than the previous one
var shiftDotsBy = (selectedTabIndex - 1) * 20;
var dotsCurrentPos = $("#tabmenunav").offset();
// Based on the original position of the dots determined outside this event, shift the dots by how far each tab extends down
$("#tabmenunav").offset({top: (dotsOrigPos.top+shiftDotsBy), left: dotsCurrentPos.left});

采纳这些想法,你应当对你想要 do子出现和转变的控制权。

问题回答

暂无回答




相关问题
getGridParam is not a function

The HTML: <a href="javascript:void(0)" id="m1">Get Selected id s</a> The Function: jQuery("#m1").click( function() { var s; s = jQuery("#list4").getGridParam( selarrrow )...

selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

jQuery cycle page with links

I am using the cycle plugin with pager functionality like this : $j( #homebox ) .cycle({ fx: fade , speed: fast , timeout: 9000, pager: #home-thumbs , ...

jquery ui dialog opens only once

I have a button that opens a dialog when clicked. The dialog displays a div that was hidden After I close the dialog by clicking the X icon, the dialog can t be opened again.

jConfirm with this existing code

I need help to use jConfirm with this existing code (php & Jquery & jAlert). function logout() { if (confirm("Do you really want to logout?")) window.location.href = "logout.php"; } ...

Wrap text after particular symbol with jQuery

What I m trying to do, is wrap text into div inside ll tag. It wouldn t be a problem, but I need to wrap text that appears particularly after "-" (minus) including "minus" itself. This is my html: &...

热门标签