-
Notifications
You must be signed in to change notification settings - Fork 0
/
How-to-Create-an-Animated-Alert-box.html
513 lines (448 loc) · 20.7 KB
/
How-to-Create-an-Animated-Alert-box.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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name='robots' content='index, follow, max-image-preview:large, max-snippet:-1, max-video-preview:-1' />
<meta http-equiv="Permissions-Policy" content="interest-cohort=()">
<meta http-equiv="content-language" content="en">
<meta name="referrer" content="strict-origin-when-cross-origin">
<meta name="author" content="DarkSoul">
<!-- Favicon -->
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
<link rel="manifest" href="/site.webmanifest">
<meta name="keywords" content="DarkSoul CodePen, How to Create an Animated Alert box , Animating Alert box, create an alert box with animations using css, create and style an alert box, Styling dismissing alerts in html, how to create a closing alert box, Dark Soul Codepens, DarkSoul CodePen How To's Blogs, DarkSoul UI/UX Designs, DarkSoul Codedamn" />
<meta name="description" content="Discover how to create an animated alert box with our detailed guide on DarkSoul CodePen. Download the source code and follow the step-by-step procedure to easily create your own animated alert box." />
<title>How to Create an Animated Alert box - DarkSoul CodePen</title>
<!-- Bootstrap core CSS -->
<link href="vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<!-- Additional CSS Files -->
<link rel="stylesheet" href="assets/css/fontawesome.css">
<link rel="stylesheet" href="assets/css/darksoul-codepen.css">
<link rel="stylesheet" href="assets/css/owl.css">
<link rel="stylesheet" href="assets/css/animate.css">
<link rel="stylesheet"href="https://unpkg.com/swiper@7/swiper-bundle.min.css"/>
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@100;200;300;400;500;600;700;800;900&display=swap" rel="stylesheet">
<style>
textarea
{
resize: none;
font-family: 'Trebuchet MS', 'Lucida Sans Unicode', 'Lucida Grande', 'Lucida Sans', Arial, sans-serif;
font-size: large;
min-height: 400px;
background-color: rgba(19, 19, 19, 0.44);
border: none;
border-radius: 15px;
font-weight: 500;
color: rgb(255, 255, 255);
}
p{
color: #ffffff;
margin: auto;
}
li
{
list-style-type: square;
color: #ffffff;
}
strong
{
color: #B1E3FA;
}
h1
{
font-weight: 900 !important;
margin-bottom: 40px;
}
h2,h4
{
font-weight: 900 !important;
}
/* width */
::-webkit-scrollbar
{
width: 5px;
}
/* Track */
::-webkit-scrollbar-track
{
background-color: rgba(226, 247, 255, 0);
}
/* Handle */
::-webkit-scrollbar-thumb
{
background: #B1E3FA;
border-radius: 10px;
height: 10px;
width: 3px;
}
.most-popular p
{
text-align: justify;
}
.youtube-container
{
display: flex;
justify-content: center;
margin-top: 60px;
}
.youtube-container iframe
{
aspect-ratio: 16 / 9;
width: 100% !important;
border-radius: 25px;
}
</style>
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-0XRHJTRGGH"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-0XRHJTRGGH');
</script>
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-9669180356185936"
crossorigin="anonymous"></script>
<!-- Clarity tracking code for https://darksoul-codepen.github.io/ -->
<script>
(function(c,l,a,r,i,t,y){
c[a]=c[a]||function(){(c[a].q=c[a].q||[]).push(arguments)};
t=l.createElement(r);t.async=1;t.src="https://www.clarity.ms/tag/"+i+"?ref=bwt";
y=l.getElementsByTagName(r)[0];y.parentNode.insertBefore(t,y);
})(window, document, "clarity", "script", "k6ctefq607");
</script>
</head>
<body>
<!-- ***** Preloader Start ***** -->
<div id="js-preloader" class="js-preloader">
<div class="preloader-inner">
<span class="dot"></span>
<div class="dots">
<span></span>
<span></span>
<span></span>
</div>
</div>
</div>
<!-- ***** Preloader End ***** -->
<!-- ***** Header Area Start ***** -->
<header class="header-area header-sticky" style="background-color: rgba(0, 0, 0, 0);">
<div class="container" style="padding: 0px;">
<div class="row">
<div class="col-12">
<nav class="main-nav">
<!-- ***** Logo Start ***** -->
<a href="https://darksoul-codepen.github.io/" class="logo">
<img src="assets/images/logo.png" alt="DarkSoul CodePen - Logo" width="100%">
</a>
<!-- ***** Logo End ***** -->
<!-- ***** Search End ***** -->
<div class="darksoul-search-bar" id="searchbar">
<i class="fa fa-search"></i>
<input id="searchbarinput" class="darksoul-search-bar-input" type="text" name="search" id="searchval" placeholder="Type something" />
<div class="darksoul-dropdown" id="dropdown">
<ul id="resultlist">
<a href="https://darksoul-codepen.github.io/How-to-center-an-image-using-display-flex.html"><li><p>How to Center an Image Using Display Flex</p></li></a>
<a href="https://darksoul-codepen.github.io/How-to-create-and-style-buttons-like-bootstrap.html"><li><p>How to Create and Style Buttons like Bootstrap</p></li></a>
<a href="https://darksoul-codepen.github.io/How-to-Create-an-Animated-Alert-box.html"><li><p>How to Create an Animated Alert Box</p></li></a>
<a href="https://darksoul-codepen.github.io/How-to-Find-the-Size-of-a-GitHub-Repository.html"><li><p>How to Find the Size of a GitHub Repo</p></li></a>
<a href="https://darksoul-codepen.github.io/How-to-merge-Video-and-Text-in-PPT.html"><li><p>How to Merge Video and Text in PPT</p></li></a>
<a href="https://darksoul-codepen.github.io/How-to-merge-Picture-and-Text-in-PPT.html"><li><p>How to Merge Picture and Text in PPT</p></li></a>
<a href="https://darksoul-codepen.github.io/CSS-Shapes-Lab.html"><li><p>CSS Shapes Lab Codedamn</p></li></a>
<a href="https://darksoul-codepen.github.io/Header-Tag-Lab.html"><li><p>Header Tag Lab Codedamn</p></li></a>
<a href="https://darksoul-codepen.github.io/Radio-Buttons-Lab.html"><li><p>Radio Buttons Lab Codedamn</p></li></a>
<a href="https://darksoul-codepen.github.io/Fibonacci-Generator-Lab.html"><li><p>Fibonacci Generator Lab Codedamn</p></li></a>
<a href="https://darksoul-codepen.github.io/Color-Change-Lab.html"><li><p>Color Change Lab Codedamn</p></li></a>
<a href="https://darksoul-codepen.github.io/Glassy-Date-Time-Weather-Widget.html"><li><p>Glassy Date,Time & Weather Widget CodePen</p></li></a>
<a href="https://darksoul-codepen.github.io/Glassy-Music-Player.html"><li><p>Glassy Music Player CodePen</p></li></a>
<a href="https://darksoul-codepen.github.io/Circular-Navigation-Menu.html"><li><p>Circular Navigation Menu CodePen</p></li></a>
<a href="https://darksoul-codepen.github.io/Neumorphic-Theme-Toggle-Switch.html"><li><p>Neumorphism Toggle Switch CodePen</p></li></a>
<a href="https://darksoul-codepen.github.io/Glowing-Border-Button.html"><li><p>Glowing Border Button CodePen</p></li></a>
<a href="https://darksoul-codepen.github.io/Sticky-Search-Bar.html"><li><p>Sticky Search Bar CodePen</p></li></a>
<a href="https://darksoul-codepen.github.io/Glowing-Gradient-Border-cards.html"><li><p>Glowing Gradient Border Cards CodePen</p></li></a>
<a href="https://darksoul-codepen.github.io/Hover-Fill-Card.html"><li><p>Hover Fill Card CodePen</p></li></a>
<a href="https://darksoul-codepen.github.io/Hover-Fill-Button.html"><li><p>Hover Fill Button CodePen</p></li></a>
<a href="https://darksoul-codepen.github.io/Preloader.html"><li><p>Preloader CodePen</p></li></a>
</ul>
</div>
</div>
<!-- ***** Search End ***** -->
<!-- ***** Menu Start ***** -->
<ul class="nav">
<li><a href="https://darksoul-codepen.github.io/">Home</a></li>
<li><a href="posts.html" class="active">Posts</a></li>
<li><a href="codepen.html">CodePens</a></li>
<li><a href="contact.html">Contact</a></li>
<li><a href="about.html">About Me <img src="assets/images/profile-header.png" alt="DarkSoul Profile"></a></li>
</ul>
<a class='menu-trigger'>
<span>Menu</span>
</a>
<!-- ***** Menu End ***** -->
</nav>
</div>
</div>
</div>
</header>
<!-- ***** Header Area End ***** -->
<div class="container">
<div class="row">
<div class="col-lg-12">
<div class="page-content">
<!-- ***** Banner Start ***** -->
<div class="main-banner">
<div class="row">
<div class="col-lg-7">
<div class="header-text">
<h1 style="color: #38B6FF; font-size: xx-large;">How to <b style="color: #000000;">Create an Animated</b> Alert Box</h1>
<h6 style="color: black;">How To's</h6>
<div class="main-button">
<a href="How-to-Create-an-Animated-Alert-box/Preview-How-to-Create-an-Animated-Alert-box.html">Preview</a>
<a href="Zips/How-to-Create-an-Animated-Alert-box.zip" download>Download Source code</a>
<a href="How-to-Create-an-Animated-Alert-box-YouTube-Tutorial-Video.html">Watch YouTube Tutorial</a>
</div>
</div>
</div>
</div>
</div>
<!-- ***** Banner End ***** -->
<!-- ***** Most Popular Start ***** -->
<div class="most-popular">
<div class="row">
<div class="col-lg-12">
<div class="heading-section">
<h4>Procedure</h4>
<div class="row">
<p><b>HTML Structure:</b></p>
<ul>
<li style="margin-left: 25px;">The HTML code includes a div element with the id 'jsalert'. This div represents the alert box and is initially hidden.</li>
<li style="margin-left: 25px;">Inside the div, there's a message "This is a success alert box!" and a button to close the alert.</li>
<li style="margin-left: 25px;">A separate button outside the div is labeled "Submit", which will trigger the alert box to appear.</li>
</ul>
<p><b>CSS Styling:</b></p>
<ul>
<li style="margin-left: 25px;">Font and Layout: The body uses custom fonts from Google Fonts, and flexbox layout to center content.</li>
<li style="margin-left: 25px;">Alert Box Styles: The .darksoul-alert-js class hides the alert box by setting its width and height to 0 and display to none.</li>
<li style="margin-left: 25px;">Show Alert Styles: The .show-alert class defines the visible state of the alert box with dimensions, border-radius, box-shadow, and animation properties.</li>
<li style="margin-left: 25px;">Button Styles: The close button (.alert-close-btn) and the submit button (.darksoul-btn) have hover effects for better user interaction.</li>
<li style="margin-left: 25px;">Animation: The @keyframes animate rule defines the sliding down effect for the alert box.</li>
</ul>
<p><b>JavaScript Functionality:</b></p>
<ul>
<li style="margin-left: 25px;">The script selects the alert box div using getElementById.</li>
<li style="margin-left: 25px;">The alertbox function toggles the show-alert class on the alert box. This makes the alert box slide down into view or hide when toggled again.</li>
<li style="margin-left: 25px;">The close button call this alertbox function when clicked.</li>
</ul>
<p><b>User Interaction:</b></p>
<ul>
<li style="margin-left: 25px;">Clicking the submit button makes the alert box appear with a sliding animation.</li>
<li style="margin-left: 25px;">Clicking the close button hides the alert box.</li>
</ul>
<p>Feel free to test and tweak this code to fit your project needs!</p>
</div>
</div>
</div>
</div>
</div>
<!-- ***** Most Popular End ***** -->
<!-- ***** Most Popular Start ***** -->
<div class="most-popular">
<div class="row">
<div class="col-lg-12">
<div class="heading-section">
<h4>Html</h4>
</div>
<div class="row">
<textarea disabled id="html">
<html>
<head>
<style>
/* Internal styles goes here.. */
</style>
</head>
<body>
<div id="jsalert" class="darksoul-alert-js bg-lightgreen t-green">
<div class="darksoul-alert-content">This is a success alert box!</div>
<button type="button" onclick="alertbox()" class="alert-close-btn"></button>
</div>
<button onclick="alertbox()" class="darksoul-btn">Submit</button>
</body>
</html>
</textarea>
</div>
</div>
</div>
</div>
<!-- ***** Most Popular End ***** -->
<!-- ***** Most Popular Start ***** -->
<div class="most-popular">
<div class="row">
<div class="col-lg-12">
<div class="heading-section">
<h4>Css</h4>
</div>
<div class="row">
<textarea disabled id="css">
@import url('https://fonts.googleapis.com/css2?family=Belanosima&family=Rubik+Vinyl&display=swap');
body
{
margin: 0;
height: 100vh;
width: 100%;
display: flex;
flex-direction: column;
font-family: 'Belanosima', sans-serif;
}
.darksoul-alert-js
{
width: 0;
height: 0;
border-radius: 5px;
box-shadow: 1px 1px 10px rgb(189, 189, 189);
text-decoration: none;
display: none;
margin: auto;
}
.darksoul-alert-content
{
margin: auto;
margin-left: 20px;
display: flex;
}
.show-alert
{
position: absolute;
margin-left: auto;
left: 0;
margin-right: auto;
right: 0;
animation-name: animate;
animation-duration: 1s;
animation-iteration-count: 1;
animation-fill-mode: forwards;
width: 90%;
height: 60px;
border-radius: 5px;
box-shadow: 1px 1px 10px rgb(242, 255, 222);
text-decoration: none;
display: flex;
margin: auto;
}
.alert-close-btn
{
margin-left: auto;
margin-top: auto;
margin-bottom: auto;
margin-right: 10px;
background-size: contain;
background-image: url("Alert-Close-Btn.png");
width: 25px;
height: 25px;
cursor: pointer;
background-color: transparent;
border: none;
}
.alert-close-btn:hover
{
transform: scale(1.1);
transition: all 0.5s;
}
/* Js - Alert Box - End */
.bg-lightgreen
{
background-color: rgba(147, 220, 147, 0.288);
}
.t-green
{
color: rgb(1, 120, 1);;
}
.darksoul-btn
{
all: unset;
margin: auto;
background-color: rgba(147, 220, 147, 0.592);
width: 100px;
height: 40px;
border-radius: 5px;
text-align: center;
cursor: pointer;
}
.darksoul-btn:hover
{
transition: all 0.2s;
background-color: rgba(147, 220, 147, 0.814);
}
@keyframes animate
{
0%{top: 0;}
100%{top: 70px;}
}
</textarea>
</div>
</div>
</div>
</div>
<!-- ***** Most Popular End ***** -->
<!-- ***** Most Popular Start ***** -->
<div class="most-popular">
<div class="row">
<div class="col-lg-12">
<div class="heading-section">
<h4>Js</h4>
</div>
<div class="row">
<textarea disabled id="js">
const jsalert = document.getElementById("jsalert");
function alertbox()
{
jsalert.classList.toggle("show-alert");
}
</textarea>
</div>
</div>
</div>
</div>
<!-- ***** Most Popular End ***** -->
<!-- ***** Gaming Library Start ***** -->
<div class="gaming-library">
<div class="col-lg-12">
<div class="heading-section">
<h4>Output Screenshot</h4>
</div>
<img src="How-to-Create-an-Animated-Alert-box/Output-Screenshot-How-to-Create-an-Animated-Alert-box.png" alt="Output Screenshot - How-to-Create-an-Animated-Alert-box" style="width: 100%; border-radius: 10px;"/>
<p> </p>
<div class="col-lg-12">
<div class="main-button">
<a href="How-to-Create-an-Animated-Alert-box/Preview-How-to-Create-an-Animated-Alert-box.html">View Live Output</a>
</div>
</div>
</div>
<!-- ***** Gaming Library End ***** -->
</div>
</div>
</div>
</div>
<footer>
<div class="container">
<div class="row">
<div class="col-lg-12">
<p>Copyright © 2024 <a href="https://darksoul-codepen.github.io/">DarkSoul CodePen</a> | <a href="https://darksoul-codepen.github.io/Disclaimer.html">Disclaimer</a> | <a href="https://darksoul-codepen.github.io/Privacy-policy.html">Privacy Policy</a> | <a href="https://darksoul-codepen.github.io/FAQ.html">FAQ</a> | <a href="https://darksoul-codepen.github.io/sitemap.xml">Sitemap</a></p>
<p><img src="assets/images/codepen_logo.png" alt="Codepen Logo" style="max-width: 20px;"/><a href="https://codepen.io/DarkSoul-" target="_blank" > CodePen</a> | <img src="assets/images/dribbble_logo.png" alt="Dribbble Logo" style="max-width: 20px;"/><a href="https://dribbble.com/dark-soul" target="_blank" > Dribbble</a> | <img src="assets/images/instagram-white-icon.webp" alt="Instagram Logo" style="max-width: 20px;"/><a href="https://www.instagram.com/dark.soul.io/" target="_blank"> Instagram</a> | <img src="assets/images/YouTube-Logo.png" alt="YouTube Logo" style="max-width: 20px;"/><a href="https://www.youtube.com/channel/UCooCOD2j8Q4Y9ysYZIFzI_w" target="_blank"> YouTube</a></p>
</div>
</div>
</div>
</footer>
<!-- Scripts -->
<!-- Bootstrap core JavaScript -->
<script src="vendor/jquery/jquery.min.js"></script>
<script src="vendor/bootstrap/js/bootstrap.min.js"></script>
<script src="assets/js/isotope.min.js"></script>
<script src="assets/js/owl-carousel.js"></script>
<script src="assets/js/tabs.js"></script>
<script src="assets/js/popup.js"></script>
<script src="assets/js/custom.js"></script>
<script src="assets/js/search.js"></script>
</body>
</html>