Как это делается?
Подскажите пожалуйста каким скриптом и какой библиотекой реализуется данный эфект?
http://pizza2dom.ru/pizza При наведении на карточку товара рисуются линии бордера. |
mishanay,
В данном случае, div, установленный с positon:absolute за картинкой и увеличивающийся в размере при наведении, div(ов) два на одну карточку, - установленны по диагонали, окрас бордеров у этих div только c двух прилегающих сторон Оба div в общем обрамлении - третьим |
Что-то не пойму почему происходит смена событий при движении мыши "по" диву box... :blink:
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<!--
<link rel="stylesheet" type="text/css" href="tmp.css" />
-->
<style type="text/css">
.box {
position: relative;
background-color: #ffffff;
}
.border {
position: absolute;
width: 0;
height: 0;
}
.up {
top: 0;
right: 0;
border-top: 2px solid #ffffff;
border-right: 2px solid #ffffff;
}
.dn {
left: 0;
bottom: 0;
border-left: 2px solid #ffffff;
border-bottom: 2px solid #ffffff;
}
</style>
<script type="text/javascript">
$(document).ready(function (){
$('.box').mouseover(function (){
var o=$('.border');
o.css({
borderColor: 'green',
});
o.animate({
width: '50%',
height: '50%'
});
});
$('.box').mouseout(function (){
var o=$('.border');
o.animate({
width: 0,
height: 0
});
o.css({
borderColor: '#ffffff',
});
});
});
</script>
</head>
<body>
<div class='box'>
<div class='border up'></div>
<div class='border dn'></div>
<img src='http://pizza2dom.ru/image/cache/data/pizza/margarita-250x250.jpg' />
</div>
</body>
</html>
|
Я могу только предположить что анимация зацикливается и ее надо остановить после первого воспроизведения
|
Цитата:
Почему-то события mouseout и mouseover mouseout срабатывают при движении по ДИВу...
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<!--
<link rel="stylesheet" type="text/css" href="tmp.css" />
-->
<style type="text/css">
.box {
position: relative;
background-color: #ffffff;
}
.border {
position: absolute;
width: 0;
height: 0;
}
.up {
top: 0;
right: 0;
border-top: 2px solid #ffffff;
border-right: 2px solid #ffffff;
}
.dn {
left: 0;
bottom: 0;
border-left: 2px solid #ffffff;
border-bottom: 2px solid #ffffff;
}
</style>
<script type="text/javascript">
$(document).ready(function (){
$('.box').mouseover(function (){
alert(1);
var o=$('.border');
o.css({
borderColor: 'green',
});
o.animate({
width: '50%',
height: '50%'
});
});
$('.box').mouseout(function (){
alert(2);
var o=$('.border');
o.animate({
width: 0,
height: 0
});
o.css({
borderColor: '#ffffff',
});
});
});
</script>
</head>
<body>
<div class='box'>
<div class='border up'></div>
<div class='border dn'></div>
<img src='http://pizza2dom.ru/image/cache/data/pizza/margarita-250x250.jpg' />
</div>
</body>
</html>
|
Да это действительно странно! Где уважаемые знатоки? Помогите разобраться!
|
Цитата:
используйте события leave и enter http://jquery-docs.ru/events/mouseleave/ |
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<!--
<link rel="stylesheet" type="text/css" href="tmp.css" />
-->
<style type="text/css">
.box {
position: relative;
background-color: #ffffff;
}
.border {
position: absolute;
width: 0;
height: 0;
}
.up {
top: 0;
right: 0;
border-top: 1px solid #ffffff;
border-right: 1px solid #ffffff;
}
.dn {
left: 0;
bottom: 0;
border-left: 1px solid #ffffff;
border-bottom: 1px solid #ffffff;
}
</style>
<script type="text/javascript">
$(document).ready(function (){
$('.box').mouseover(function (){
var o=$('.border');
o.css({
borderColor: 'green',
});
o.stop().animate({
width: '50%',
height: '50%'
},600);
});
$('.box').mouseout(function (){
var o=$('.border');
o.stop().animate({
width: 0,
height: 0
},400, "linear", function (){
o.css({
borderColor: '#fff',
});
});
});
});
</script>
</head>
<body>
<div class='box'>
<div class='border up'></div>
<div class='border dn'></div>
<img src='http://pizza2dom.ru/image/cache/data/pizza/margarita-250x250.jpg' />
</div>
</body>
</html>
|
Цитата:
Причем "моргание" происходит даже если не двигать по картинке, а например в правой стороне ДИВа... |
Цитата:
Во фрейме, события over для javascrip прерываются еще и таймированием, к примеру с родительской, нун не в топике тестить |
| Часовой пояс GMT +3, время: 09:04. |