HTML5
1
|
<a class="more_btn" href="">cilck<span></span></a>
|
CSS3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
.more_btn {
overflow: hidden;
display: block;
position: relative;
width: 160px;
margin-top: 45px;
border: 1px solid skyblue;
font-size: 13px;
font-weight: 700;
line-height: 54px;
text-align: center;
color: #222;
-webkit-transition: color .4s;
transition: color .4s;
font-family: 'Montserrat'
}
.more_btn span {
position: absolute;
z-index: -1;
display: block;
width: 0;
height: 0;
border-radius: 50%;
background-color: skyblue;
-webkit-transition: all .4s ease-in-out;
transition: all .4s ease-in-out;
-webkit-transform: translate(-50%, -50%);
transform: translate(-50%, -50%)
}
.more_btn:hover {
color: #fff
}
.more_btn:hover span {
width: 350px;
height: 350px
}
|
jQuery
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
$(function() {
$('.more_btn')
.on('mouseenter', function(e) {
var parentOffset = $(this).offset(),
relX = e.pageX - parentOffset.left,
relY = e.pageY - parentOffset.top;
$(this).find('span').css({
top: relY,
left: relX
})
})
.on('mouseout', function(e) {
var parentOffset = $(this).offset(),
relX = e.pageX - parentOffset.left,
relY = e.pageY - parentOffset.top;
$(this).find('span').css({
top: relY,
left: relX
})
});
});
|
결과
jsfiddle 주소
반응형
'jQuery' 카테고리의 다른 글
농구게임 만들기 (0) | 2019.09.26 |
---|---|
제이쿼리로 슬라이드 만들기 (0) | 2019.09.26 |
is()로 요소 검사하기 (0) | 2019.09.26 |
jQuery 효율적으로 사용하기 (0) | 2019.09.25 |
on이벤트에 파라미터 전달 (0) | 2019.09.25 |