0
내 웹 사이트에서 메뉴를 표시하려면 아래 js를 사용하십시오. 브라우저 창이 작을 때 위쪽으로 드롭 다운을 표시하는 것 외에는 잘 작동합니까? 어떻게하면 창 크기, 드롭 다운 메뉴가 아래쪽으로 보여 지든이 JS를 만들 수 있습니까?브라우저 창 크기가 작을 때 메뉴가 위쪽으로 표시됩니다.
코드 끝에 y = 0을 만들려고했지만 행운이 없었습니다.
var flexdropdownmenu = {
arrowpath: '../Uploadedfiles/System/Scripts/flexdropdown/arrow.gif', //full URL or path to arrow image
animspeed: 200, //reveal animation speed (in milliseconds)
showhidedelay: [150, 150], //delay before menu appears and disappears when mouse rolls over it, in milliseconds
//***** NO NEED TO EDIT BEYOND HERE
startzindex: 1000,
ismobile: navigator.userAgent.match(/(iPad)|(iPhone)|(iPod)|(android)|(webOS)/i) != null, //boolean check for popular mobile browsers
builtflexmenuids: [], //ids of flex menus already built (to prevent repeated building of same flex menu)
positionul: function ($, $ul, e, $anchor) {
var istoplevel = $ul.hasClass('jqflexmenu') //Bool indicating whether $ul is top level flex menu DIV
var docrightedge = $(document).scrollLeft() + $(window).width() - 40 //40 is to account for shadows in FF
var docbottomedge = $(document).scrollTop() + $(window).height() - 40
if (istoplevel) { //if main flex menu DIV
var offsets = $anchor.offset()
var anchorsetting = $anchor.data('setting')
var x = offsets.left + anchorsetting.useroffsets[0] + (anchorsetting.dir == "h" ? $anchor.outerWidth() : 0) //x pos of main flex menu UL
var y = offsets.top + anchorsetting.useroffsets[1] + (anchorsetting.dir == "h" ? 0 : $anchor.outerHeight())
x = (x + $ul.data('dimensions').w > docrightedge) ? x - (anchorsetting.useroffsets[0] * 2) - $ul.data('dimensions').w + $anchor.outerWidth() + (anchorsetting.dir == "h" ? -($anchor.outerWidth() * 2) : 0) : x //if not enough horizontal room to the ridge of the cursor
y = (y + $ul.data('dimensions').h > docbottomedge) ? y - (anchorsetting.useroffsets[1] * 2) - $ul.data('dimensions').h - $anchor.outerHeight() + (anchorsetting.dir == "h" ? ($anchor.outerHeight() * 2) : 0) : y
y = y - 5;
}
else { //if sub level flex menu UL
var $parentli = $ul.data('$parentliref')
var parentlioffset = $parentli.offset()
var x = $ul.data('dimensions').parentliw //x pos of sub UL
var y = 0
x = (parentlioffset.left + x + $ul.data('dimensions').w > docrightedge) ? x - $ul.data('dimensions').parentliw - $ul.data('dimensions').w : x //if not enough horizontal room to the ridge parent LI
y = (parentlioffset.top + $ul.data('dimensions').h > docbottomedge) ? y - $ul.data('dimensions').h + $ul.data('dimensions').parentlih : y
//To show the submenu downwards irrespective of the browser resolution or size
y = 0;
}
$ul.css({ left: x, top: y })
}
당신은'if' 블록뿐만 아니라 'else' 블록의 변경을해야하지 않을까요? 그런데 왜 메뉴가 화면 아래쪽으로 떨어지도록 강요하고 싶습니까? (사용자가 볼 수 없을 때 사용자가 클릭하면 어떻게됩니까?) http://jsfiddle.net에서 데모를 제공 할 수 있습니까? – nnnnnn
@nnnnnn if 조건에 y = 0을 넣어도 결과는 같습니다. 문제는 첫 번째 레벨 만 위쪽으로 가고, 그 이상의 레벨은 아래쪽을 향하게됩니다. – Anuya