30
30
box-sizing : border-box;
31
31
}
32
32
33
+ /* The snackbar - position it at the bottom and in the middle of the screen */
34
+ # snackbar {
35
+ visibility : hidden; /* Hidden by default. Visible on click */
36
+ min-width : 250px ; /* Set a default minimum width */
37
+ margin-left : -125px ; /* Divide value of min-width by 2 */
38
+ background-color : # 333 ; /* Black background color */
39
+ color : # fff ; /* White text color */
40
+ text-align : center; /* Centered text */
41
+ border-radius : 2px ; /* Rounded borders */
42
+ padding : 16px ; /* Padding */
43
+ position : fixed; /* Sit on top of the screen */
44
+ z-index : 1 ; /* Add a z-index if needed */
45
+ left : 50% ; /* Center the snackbar */
46
+ bottom : 30px ; /* 30px from the bottom */
47
+ }
48
+
49
+ /* Show the snackbar when clicking on a button (class added with JavaScript) */
50
+ # snackbar .show {
51
+ visibility : visible; /* Show the snackbar */
52
+ /* Add animation: Take 0.5 seconds to fade in and out the snackbar.
53
+ However, delay the fade out process for 2.5 seconds */
54
+ -webkit-animation : fadein 0.5s , fadeout 0.5s 2.5s ;
55
+ animation : fadein 0.5s , fadeout 0.5s 2.5s ;
56
+ }
57
+
58
+ /* Animations to fade the snackbar in and out */
59
+ @-webkit-keyframes fadein {
60
+ from {bottom : 0 ; opacity : 0 ;}
61
+ to {bottom : 30px ; opacity : 1 ;}
62
+ }
63
+
64
+ @keyframes fadein {
65
+ from {bottom : 0 ; opacity : 0 ;}
66
+ to {bottom : 30px ; opacity : 1 ;}
67
+ }
68
+
69
+ @-webkit-keyframes fadeout {
70
+ from {bottom : 30px ; opacity : 1 ;}
71
+ to {bottom : 0 ; opacity : 0 ;}
72
+ }
73
+
74
+ @keyframes fadeout {
75
+ from {bottom : 30px ; opacity : 1 ;}
76
+ to {bottom : 0 ; opacity : 0 ;}
77
+ }
78
+
33
79
.menu-logo img {
34
80
max-height : 40px ;
35
81
max-width : 100px ;
@@ -138,6 +184,12 @@ <h1>Messages</h1>
138
184
139
185
< br >
140
186
187
+ <!-- Use a button to open the snackbar -->
188
+ < button onclick ="myFunction() "> Message Staff</ button >
189
+
190
+ <!-- The actual snackbar -->
191
+ < div id ="snackbar "> This feature is Coming Soon!</ div >
192
+
141
193
< center > < h2 > You currently don't have any messages. Check back later!</ h2 > </ center >
142
194
143
195
@@ -146,6 +198,16 @@ <h1>Messages</h1>
146
198
var menu = document . querySelector ( '.menu' ) ;
147
199
menu . style . display = menu . style . display === 'flex' ? 'none' : 'flex' ;
148
200
}
201
+ function myFunction ( ) {
202
+ // Get the snackbar DIV
203
+ var x = document . getElementById ( "snackbar" ) ;
204
+
205
+ // Add the "show" class to DIV
206
+ x . className = "show" ;
207
+
208
+ // After 3 seconds, remove the show class from DIV
209
+ setTimeout ( function ( ) { x . className = x . className . replace ( "show" , "" ) ; } , 3000 ) ;
210
+ }
149
211
</ script >
150
212
</ body >
151
213
</ html >
0 commit comments