html
html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<!DOCTYPE html>
<html>
<head>
<script defer src="https://unpkg.com/@lf2com/magnet.js@latest/dist/magnet.min.js"></script>
<!--or
<script defer src="https://cdn.jsdelivr.net/gh/lf2com/magnet.js@latest/dist/magnet.min.js"></script>
-->
<title>Magnet JS Test</title>
</head>
<body>
<magnet-block attract-distance="50"
align-to="outer|center">
<red-block>magnet1</red-block>
</magnet-block>
<magnet-block attract-distance="50" align-to="outer|center">
<blue-block>magnet2</blue-block>
</magnet-block>
</body>
</html>
Enter to Rename, Shift+Enter to Preview
css
css
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
*{
box-sizing:border-box;
padding:0;
margin:0;
}
blue-block,
red-block{
display:grid;
place-items:center;
width:70px;
height:150px;
outline:1px solid;
border-radius:15px;
box-shadow: 5px 5px 5px #0003;
}
red-block{
background-color: firebrick;
color: white;
}
blue-block{
background-color: dodgerblue;
}
Enter to Rename, Shift+Enter to Preview
js
js
1
Enter to Rename, Shift+Enter to Preview
BROWSER
Console
Run