나는 최선을 다해 설명하려고 노력할 것입니다. 이 튜토리얼 http://tympanus.net/codrops/2010/06/28/awesome-cufonized-fly-out-menu/을 사용하여 내 웹 사이트의 가로 탐색 메뉴를 활용했습니다. 현재 튜토리얼에서 자바 스크립트를 조정하려고합니다. 각 링크를 마우스로 움직일 때 각 링크에서 마우스 롤오버를 유지하고 싶지만 선택한 링크를 항상 강조 표시하고 싶습니다 (현재는 기능이 없습니다).선택한 요소로 롤러 효과 구현
나는 현재 포트홀리로 링크에 있고 강조 표시되어 있으며 마지막으로 홈 버튼을 마우스로 이동하기 전에 (내 메뉴 div에서 마우스를 이동하기 전에) 내 홈 링크를 강조 표시하지만 현재 내 포트폴리오 페이지에 있습니다. 바라건대, 나는 충분히 명확하게
body{
background:#292929;
overflow: hidden;
font-family: Arial, Helvetica, sans-serif;
}
.slidingMenu {
position: absolute;
top:250px;
left: 0px;
padding-bottom: 10px;
width: 400px;
}
.slidingMenu li {
display:block;
float:left;
clear:both;
padding-left: 12px;
height: 52px;
line-height: 52px;
}
.slidingMenu li.selected{
display:block;
float:left;
clear:both;
padding-left: 12px;
height: 52px;
line-height: 52px;
}
.slidingMenu li.move {
width: 9px;
position: absolute;
z-index: 8;
background: #df0101;
background:
-webkit-gradient(
linear,
left top,
left bottom,
from(#a70404),
to(#df0101)
);
background:
-moz-linear-gradient(
top,
#a70404,
#df0101
);
-moz-border-radius: 0px 8px 8px 0px;
-webkit-border-top-right-radius: 8px;
-webkit-border-bottom-right-radius: 8px;
border-top-right-radius: 8px;
border-bottom-right-radius: 8px;
-moz-box-shadow:1px 1px 5px #000;
-webkit-box-shadow:1px 1px 5px #000;
box-shadow:1px 1px 5px #000;
}
.slidingMenu li a {
font-size:50px;
text-transform:uppercase;
text-decoration: none;
color: #FFF;
text-indent:5px;
z-index: 10;
display: block;
z-index: 10;
float: right;
line-height: 50px;
position: relative;
padding-right:10px;
}
/* Descriptions */
.slidingMenuDesc{
margin-top:40px;
position:relative;
}
.slidingMenuDesc div{
background: #df0101;
background:
-webkit-gradient(
linear,
left top,
left bottom,
from(#a70404),
to(#df0101)
);
background:
-moz-linear-gradient(
top,
#a70404,
#df0101
);
height: 52px;
right:-5px;
width:0px;
overflow:hidden;
position:absolute;
-moz-box-shadow:1px 1px 5px #000;
-webkit-box-shadow:1px 1px 5px #000;
box-shadow:1px 1px 5px #000;
-moz-border-radius: 8px 0px 0px 8px;
-webkit-border-top-left-radius: 8px;
-webkit-border-bottom-left-radius: 8px;
border-top-left-radius: 8px;
border-bottom-left-radius: 8px;
}
.slidingMenuDesc div span {
font-size:24px;
color: #f0f0f0;
display: block;
z-index: 10;
line-height: 52px;
position:absolute;
margin-left: 30px;
}
을 설명했다 다음은 메뉴 내 CSS를
$(document).ready(function(){
var $menu = $("#slidingMenu");
/**
* the first item in the menu,
* which is selected by default
*/
var $selected = $menu.find('li:first');
/**
* this is the absolute element,
* that is going to move across the menu items
* it has the width of the selected item
* and the top is the distance from the item to the top
*/
var $moving = $('<li />', {
'class' : 'move',
'top' : $selected[0].offsetTop + 'px',
'width' : $selected[0].offsetWidth + 'px'
});
/**
* each sliding div (descriptions) will have the same top
* as the corresponding item in the menu
*/
$('#slidingMenuDesc > div').each(function(i){
var $this = $(this);
$this.css('top',$menu.find('li:nth-child('+parseInt(i+2)+')')[0].offsetTop + 'px');
});
/**
* append the absolute div to the menu;
* when we mouse out from the menu
* the absolute div moves to the top (like innitially);
* when hovering the items of the menu, we move it to its position
*/
$menu.bind('mouseleave',function(){
//moveTo($selected,400);
})
.append($moving)
.find('li')
.not('.move')
.bind('mouseenter',function(){
var $this = $(this);
var offsetLeft = $this.offset().left + $(window).width() - ($this.outerWidth() + 20);
//slide in the description
$('#slidingMenuDesc > div:nth-child('+ parseInt($this.index()) +')').stop(true).animate({'width':offsetLeft+'px'},400, 'easeOutExpo');
//move the absolute div to this item
moveTo($this,400);
})
.bind('mouseleave',function(){
var $this = $(this);
var offsetLeft = $this.offset().left - 20;
//slide out the description
$('#slidingMenuDesc > div:nth-child('+ parseInt($this.index()) +')').stop(true).animate({'width':'0px'},400, 'easeOutExpo');
});
/**
* moves the absolute div,
* with a certain speed,
* to the position of $elem
*/
function moveTo($elem,speed){
$moving.stop(true).animate({
top : $elem[0].offsetTop + 'px',
width : $elem[0].offsetWidth + 'px'
}, speed, 'easeOutExpo');
}
});
입니다 :
여기 내 코드입니다. 내 자바 스크립트 기술은 매우 약하다 - 이것은 웹 사이트를 만드는 첫 번째 시도 중 하나이기 때문에 나는이 코딩 형식을 사용하기 시작했다. 사전에 도움을 주셔서 감사합니다.
지금 만들려고합니다. –
여기 [link] (http://jsfiddle.net/VYuS6/)입니다. 롤오버 애니메이션이 jsfiddle에서 올바르게 작동하지 않지만 포함 된 코드가 현재 가지고있는 코드입니다. –
나는 내 대답을 업데이 트했습니다, 그것이 당신을 위해, 환호를 희망합니다. –