File tree Expand file tree Collapse file tree 4 files changed +112
-0
lines changed
Expand file tree Collapse file tree 4 files changed +112
-0
lines changed Original file line number Diff line number Diff line change 1+ window . addEventListener ( "contextmenu" , function ( event ) {
2+ event . preventDefault ( ) ;
3+ var contextElement = document . getElementById ( "context-menu" ) ;
4+ contextElement . style . top = event . offsetY + "px" ;
5+ contextElement . style . left = event . offsetX + "px" ;
6+ contextElement . classList . add ( "active" ) ;
7+ } ) ;
8+
9+ window . addEventListener ( "click" , function ( ) {
10+ document . getElementById ( "context-menu" ) . classList . remove ( "active" ) ;
11+ } ) ;
Original file line number Diff line number Diff line change 1+ <!DOCTYPE html>
2+ < html lang ="en ">
3+ < head >
4+ < meta charset ="UTF-8 ">
5+ < meta http-equiv ="X-UA-Compatible " content ="IE=edge ">
6+ < meta name ="viewport " content ="width=device-width, initial-scale=1.0 ">
7+ < link rel ="stylesheet " href ="style.css ">
8+ < link rel ="stylesheet " href ="https://unicons.iconscout.com/release/v4.0.0/css/line.css ">
9+ < title > Custom context menu</ title >
10+ </ head >
11+ < body >
12+ < div id ="context-menu ">
13+ < div class ="item arrow-right "> < i class ="uil uil-eye "> </ i > View< i class ="uil uil-angle-right "> </ i > </ div >
14+ < div class ="item arrow-right "> < i class ="uil uil-filter "> </ i > Sort By< i class ="uil uil-angle-right "> </ i > </ div >
15+ < div class ="divider "> </ div >
16+ < div class ="item "> < i class ="uil uil-redo "> </ i > Refresh</ div >
17+ < div class ="item "> < i class ="uil uil-share "> </ i > Share</ div >
18+ < div class ="divider "> </ div >
19+ < div class ="item "> < i class ="uil uil-trash "> </ i > Delete</ div >
20+ < div class ="item "> < i class ="uil uil-setting "> </ i > Settings</ div >
21+ </ div >
22+ < script src ="app.js "> </ script >
23+ </ body >
24+ </ html >
Original file line number Diff line number Diff line change 1+ @import url ('https://fonts.googleapis.com/css2?family=Inter&display=swap' );
2+
3+ body {
4+ margin : 0 ;
5+ background : url (bg.jfif);
6+ background-repeat : no-repeat;
7+ background-size : 100% ;
8+ font-family : 'Inter' , sans-serif;
9+ }
10+
11+ # context-menu {
12+ position : fixed;
13+ z-index : 999999 ;
14+ width : 200px ;
15+ background : # fff ;
16+ border-radius : 5px ;
17+ transform : scale (0 );
18+ transform-origin : top left;
19+ box-shadow : 0px 5px 15px 0px rgb (0 , 0 , 0 , .24 );
20+ }
21+
22+ # context-menu .active {
23+ transform : scale (1 );
24+ animation : pop .3s cubic-bezier (0 , 1 , .5 , 1.08 );
25+ }
26+
27+ @keyframes pop{
28+ 0% {
29+ transform : scale (0.9 );
30+ }
31+ 100% {
32+ transform : scale (1 );
33+ }
34+ }
35+
36+ # context-menu .item {
37+ padding : 10px 10px ;
38+ font-size : 15px ;
39+ cursor : pointer;
40+ }
41+
42+
43+ # context-menu .item ::selection {
44+ background : none;
45+ }
46+
47+ # context-menu .item : hover {
48+ background : # f2f2f2 ;
49+ }
50+
51+ # context-menu .item : nth-child (1 ){
52+ border-top-left-radius : 5px ;
53+ border-top-right-radius : 5px ;
54+ }
55+
56+ # context-menu .item : nth-last-child (1 ){
57+ border-bottom-left-radius : 5px ;
58+ border-bottom-right-radius : 5px ;
59+ }
60+
61+ # context-menu .item : active {
62+ background : # dddddd ;
63+ }
64+
65+ # context-menu .item i {
66+ display : inline-block;
67+ margin-right : 5px ;
68+ }
69+
70+ .arrow-right .uil-angle-right {
71+ float : right;
72+ }
73+
74+ .divider {
75+ margin : 2px 0px ;
76+ border-bottom : 1px solid # ccc ;
77+ }
You can’t perform that action at this time.
0 commit comments