How To Create A Modal In Javascript and CSS

Поділитися
Вставка
  • Опубліковано 1 січ 2025

КОМЕНТАРІ • 131

  • @siamonadi7997
    @siamonadi7997 5 років тому +7

    you don't need an additional container div to darken other things up, this can be done with the box-shadow property;
    sth like this will do the trick : box-shadow: 0px 0px 0px 100vw rgba(0,0,0,0.6);
    apply this on your box an you wont need the container.
    great video ,thanks

    • @Wanderer2035
      @Wanderer2035 2 роки тому

      And when the demon came into our world, he blocked out the sun, and we were all engulfed in his shadow.

  • @laurathomazi
    @laurathomazi 3 роки тому +4

    I just love your tutorials, it's so easy to learn and your personality makes it even better. Really fun. Thank You

  • @wisdomelue
    @wisdomelue 3 роки тому +1

    i've watched 3 different tutorials for this, seems so hard, can't believe it's this simple, thanks man.

  • @fernandozamora6127
    @fernandozamora6127 2 роки тому

    Bro you saved my life with this! I just kinda gave up and stared at my screen for an hour but now I see what I was doing wrong! Thank you!!

    • @Wanderer2035
      @Wanderer2035 2 роки тому

      I’d recommend watching the tutorial on it first, then after you have an idea practice building it on your own, instead of building it on your own before you watch the tutorial. It will save you from losing your hair.

  • @pratyushkumar5740
    @pratyushkumar5740 3 роки тому +1

    Awesome, I'll be integrating this for my production grade application. Thankyou so much.

  • @andrewkamoha4666
    @andrewkamoha4666 2 роки тому

    Would the tag simplify this tutorial?

  • @leoMC4384
    @leoMC4384 2 роки тому

    I'm rebuilding the frontend of this full stack project without Bootstrap. I hate dealing with CSS but I must learn to work with it if I have to. One of the things to replace are modals. Thank you so much. 👏👏👏

  • @f450fpv7
    @f450fpv7 7 місяців тому

    Thank you for sharing your knowledge!
    Congratulations on your talent in making what is difficult to learn easy to learn for people like me who are just starting out.

  • @adeisaac
    @adeisaac 5 років тому +2

    I have watched Dev's videos, and although he sound very very unserious, he is very very helpful. Thanks man, your Javascript course was very helpful.

  • @magalyriera
    @magalyriera 2 роки тому

    Thank you for putting this video together! you are an excellent teacher! Greetings from Ecuador

  • @tawongachauluntha2880
    @tawongachauluntha2880 2 роки тому

    Finally I have managed to create a modal with js .. thanks man

  • @Onomandah
    @Onomandah 3 роки тому

    Hey! Just wanted to say that I really appreciate your work and your sense of humor! :)

  • @Ram-m1s9b
    @Ram-m1s9b 3 роки тому

    Really.. awesome like very helpful for me 💗
    Love you too all your

  • @jennamaegabriel
    @jennamaegabriel 3 роки тому +2

    OMYG. IT WORKED 😭 Thank you for this, sir!

  • @MissAndieG21
    @MissAndieG21 4 роки тому +4

    This was a really cool and easy way to use JavaScript.
    Thank you!

  • @ChampagneRaji
    @ChampagneRaji 6 років тому +8

    Dope! Thanks a lot for this man! Super easy to follow for a beginner like me haha

  • @denciosantos5316
    @denciosantos5316 4 роки тому

    hi am new in web development i just got your lesson very straight forward approach very nice.

  • @GiancarloCarccamo
    @GiancarloCarccamo 4 роки тому +3

    Thanks bro for sharing your knowlegde with us, Saludos desde Honduras.

  • @damendiaye3440
    @damendiaye3440 3 роки тому

    Thank you so simple so undestandable good job teacher

  • @abdianrizkyramadan1535
    @abdianrizkyramadan1535 4 роки тому +2

    Love this man🤙 if i need any component, i watch your tutorial

  • @t4vex2
    @t4vex2 Рік тому

    congrats man, what a tutorial

  • @santiagoventura3211
    @santiagoventura3211 4 роки тому

    Genio! te sigo desde Argentina y a pesar qu eno entienda muy bien ingles, disfruto muho tus videos.

  • @teymurnasirli
    @teymurnasirli 4 роки тому +1

    It is a great tutorial simple explanation and a great approach. It will be better also show us how to apply the close event when the user click the outside of the module

  • @jerryleemelton1860
    @jerryleemelton1860 2 роки тому

    Dude, thanks so much for this! This was quick and easy and worked like a charm.

  • @NicolasCoutinho-l5f
    @NicolasCoutinho-l5f 4 роки тому +1

    Thanks, buddy, I was having a hard time before watching your video. And again, thanks bro.

  • @NNNedlog
    @NNNedlog 3 роки тому

    Thanks a lot Dev. Ed. You're the best

  • @rault8611
    @rault8611 6 років тому +12

    why dont use display property css?

    • @developedbyed
      @developedbyed  6 років тому +36

      great question! I don't use display: none because that cannot be transitioned. So we cannot have the "fade in effect" :)

    • @NNNedlog
      @NNNedlog 3 роки тому

      @@developedbyed thanks for clearing my doubts Dev Ed. You're the best

  • @xuanhuynh5952
    @xuanhuynh5952 4 роки тому

    It's awesome. Thank you Ed.

  • @mojr6874
    @mojr6874 4 роки тому

    Wow you are the master man I really appreciate your work your videos really help me

  • @prophetgadedemdzomeku3034
    @prophetgadedemdzomeku3034 3 роки тому

    Your videos are very simple and you explain really well. You make Js very much interactive. Even 2021 this is the best Tutorial i have seen. Thanks. I want to know how i can get the complete course.

  • @RameenFallschirmjager
    @RameenFallschirmjager 5 років тому +5

    you code butter smooth bro!

  • @ZANES-YT
    @ZANES-YT 4 роки тому +1

    thank you so much you helped me out with a school project and I learned something new!

  • @LasCosasComoSonCR
    @LasCosasComoSonCR 4 роки тому

    I want to say so many thanks! Very helpful! I

  • @thegoat23452
    @thegoat23452 4 роки тому

    Thanks Dev Ed for all

  • @mugambo5505
    @mugambo5505 3 роки тому

    Great vedio

  • @haobamjameskumar3962
    @haobamjameskumar3962 4 роки тому

    Best teacher ever

  • @coolguy9616
    @coolguy9616 3 роки тому

    Hey man you are the best

  • @galipruz1690
    @galipruz1690 2 роки тому

    amazing man! thank you!

  • @sadstar7520
    @sadstar7520 3 роки тому

    Thank you for sharing Ed 😂 don't be too nervous dude !!

  • @MrsLalaina
    @MrsLalaina 3 роки тому

    Hello !
    Thanks, that's great !, now how to make it responsive?

  • @muhammadabdelbari9128
    @muhammadabdelbari9128 2 роки тому

    absolutely helpful thanks a lot

  • @raulsantandertirado4400
    @raulsantandertirado4400 4 роки тому +1

    Perhaps you could add the functionality of closing the modal by clicking outside of it?

  • @callmequeen17
    @callmequeen17 3 роки тому +1

    the papa bless made my heart happy c:

  • @mohamedelkashef7771
    @mohamedelkashef7771 4 роки тому

    You are amazing man keep going ❤️❤️❤️

  • @fzrahmadan
    @fzrahmadan 2 роки тому

    thanks man, i really appreciate it!

  • @shahbokhari
    @shahbokhari 5 років тому +1

    Hi Ed, what if you use the modal class to multiple elements of the page for different content to show up in the modal itself. Making it a reusable modal. How would you go about that? Could you please make a tutorial about that. Thank You so much

    • @shazbaz5695
      @shazbaz5695 4 роки тому

      did you figure it out?

    • @Bayo106
      @Bayo106 4 роки тому

      I'm guessing you'll create an array of objects with information, then forEach of those add an event listener so that when they're clicked on, or whatever, the contents of the modal will be specific to each object

  • @lisofsky8151
    @lisofsky8151 3 роки тому

    Спасибо !!! то что нужно для понимания !! долго искал

  • @samueltorres2485
    @samueltorres2485 4 роки тому

    This was helpful, thanks!

  • @evanilsonp.8183
    @evanilsonp.8183 2 роки тому

    Amazing!

  • @urmilaroy2747
    @urmilaroy2747 4 роки тому

    Please tell theme you used for this video

  • @amandioreal2293
    @amandioreal2293 3 роки тому

    Hi I'm tryning to show in a modal the value of a item inside a list group. Can you help in this?

  • @camilogarcia1325
    @camilogarcia1325 Рік тому

    I have an array of objets with has properties, I want it show them on click event, but don´t no how to show e.target.value imagen with each object :s

  • @JustinPaulGT
    @JustinPaulGT 2 роки тому

    Thank you bro 💓

  • @ferdinadcusihuamanayma2692
    @ferdinadcusihuamanayma2692 4 роки тому

    thank you for your totorials!

  • @deivi3697
    @deivi3697 2 роки тому

    Why the X to close de modal top and right 10 px, always takes you to that point?

  • @agu4071
    @agu4071 3 роки тому

    i got a problem.. i have modal with some photos that can be closed by clicking on its background, but when i open one photo (opens as another modal) and close it by clicking its background I cant close the first modal by clicking its background. It works only when i don't open any photo. Am I doing something wrong? maybe its not good to make modal in modal or something..
    i use for both modals (with different names obviously):
    window.onclick = function closeModal (event)
    {
    if (event.target == imgModalBg)
    {
    imgModalBg.style.display = 'none';
    }
    }

  • @chinchuthomas7
    @chinchuthomas7 2 роки тому

    Nice video.

  • @heirsofchrist
    @heirsofchrist 4 роки тому

    Big Bro, it really helped. Thanks.

  • @epizarro309
    @epizarro309 4 роки тому

    Great video!

  • @dexterdragons
    @dexterdragons 4 роки тому

    hey, how to modal popup - createElement and innerHTML? open and close btn?

  • @aishikaroy6484
    @aishikaroy6484 4 роки тому

    Can I just use modal to make a basic light box?

  • @sovereignlivingsoul
    @sovereignlivingsoul 4 роки тому

    Nice video, maybe update with the arrow function. Thanks for sharing.

  • @nasusayt
    @nasusayt 3 роки тому

    thankyou very much sir

  • @ldawg214
    @ldawg214 5 років тому +2

    I've been really digging your videos. I do have a question though. How easy would it be to use this for multiple modals? For example, I'm creating my portfolio and I have a total of six projects listed on the home page and I'd like to fire a different modal for each project. This is awesome but it's only good for one modal and I'm trying to wrap my head around how to create multiple modals without going overboard in the code. Anyway, great work. Your videos are very engaging and entertaining.

    • @developedbyed
      @developedbyed  5 років тому +2

      If all your modals are similar ( 1 header and paragraph etc). You could just use one modal in your html. When you want to have a different one you could change the textContent of them with javascript. Otherwise you would pretty much have to create multiple html modals and show and hide them with js.

    • @zahradeenie
      @zahradeenie 5 років тому

      @@developedbyed It would be great if you could do a part-two on the multiple modals - can't find anything online that explains how to do it as simply as you do

    • @Bayo106
      @Bayo106 4 роки тому

      @@zahradeenie you don't need multiple. Just one modal and change the contents dynamically with JavaScript

    • @adarshtiwari7395
      @adarshtiwari7395 3 роки тому

      I have the exact same requirements. Did you find a potential solution? Could you help me if you did?

  • @fabrice9403
    @fabrice9403 5 років тому

    how can you add animation on like it comes from top to the center. and to click on an empty space to close it. how to do that?

  • @charbelmedia3014
    @charbelmedia3014 4 роки тому +4

    Dev: Nothing does anything
    Me: Anything does Nothing
    Love your video bro! Ignore that I just made fun of you coz this video helped me a lot.
    I'm serious 😑😶😐

  • @adison2117
    @adison2117 3 роки тому +1

    Is the visibility: hidden needed? Isnt just the opacity: 0 enough to hide the modal?

    • @GLimao
      @GLimao 3 роки тому

      'cause if you put just opacity, all in the modal still there, but not visible, so the user can interact with everything there. It's like an invisible box. When you put the visibility: hidden, the modal is hidden, it's like is no modal there.
      And he use both, because one complement the other, and opacity is better for transition.
      I hope you can undertand this, I am not so good in english haha

    • @adison2117
      @adison2117 3 роки тому

      Ok i see, but there is also pointer events: none which would do the same in combination of opacity and is more often used by people. So opacity would make the box invisible and pointer events would make it non interactive with a user. Am i right?

    • @GLimao
      @GLimao 3 роки тому

      @@adison2117 yes, you can use pointer events and use just opacity

  • @shazbaz5695
    @shazbaz5695 4 роки тому +1

    It only works if the modal and the button are on the same page. What if you want the model and the button separated in two different HTML pages.. how do you get it to work then?

    • @michaelanderson6727
      @michaelanderson6727 3 роки тому

      Include the html, javascript and css code in every page of your project. It's that simple. I hope you still need this

  • @AAARONSD
    @AAARONSD 3 роки тому

    Thanks for the upload. I followed the directions and code to make my first modal and it only seemed to work on Code Pen but as soon as I plugged it into Visual Studios Live Server it didnt work. Anyone know why?

    • @AAARONSD
      @AAARONSD 3 роки тому

      The button is there but when I click it it does not open the modal.

  • @vishwajeetraj11
    @vishwajeetraj11 4 роки тому

    yeah when the content overflows it doesnt show the header part of modal its chopped off.

  • @shubhambhatt329
    @shubhambhatt329 3 роки тому

    thank u bro becz of i make this model

  • @vartikadehalvi5664
    @vartikadehalvi5664 3 роки тому

    how do we do it with gsap?

  • @allan4317
    @allan4317 2 роки тому

    Nice pace of tutorial, except I would have liked to see the first (top) half of the CSS code so I could replicate everything while learning.

  • @CheMansur
    @CheMansur 6 років тому

    Helped alot, thanks :D

  • @ninadparkar6998
    @ninadparkar6998 4 роки тому

    How to make modal unscrollable?

  • @issaissifou3579
    @issaissifou3579 4 роки тому

    Thank you so much!

  • @anniely7311
    @anniely7311 6 років тому +2

    From what I can tell, my code looks identical. However, none of the code, after hidden visibility including the js, seems to be working for me. Any pointers? No pun intended :D

    • @developedbyed
      @developedbyed  6 років тому

      Can you copy paste your code on github?

    • @anniely7311
      @anniely7311 6 років тому

      @@developedbyed Yes! Please follow this link. Thank you!
      github.com/annielly/balance

    • @uimonk
      @uimonk 5 років тому

      ua-cam.com/video/8A6mqAu4llg/v-deo.html
      this video has source code with explanation

  • @stefaniaalbornozibanez3322
    @stefaniaalbornozibanez3322 4 роки тому

    gracias capo te agradezco muchisimo

  • @joelgeleta2266
    @joelgeleta2266 4 роки тому

    I am having troubles when i try to apply it to two buttons. The first one works fine but the second doesn't. Any help would be appreciated.

    • @omray7125
      @omray7125 4 роки тому +2

      You would need to use document.querySelectorAll and use a for loop to go through all the indexes in the array that creates.

  • @ansariarbaz3374
    @ansariarbaz3374 4 роки тому

    IT IS AWESOME

  • @sakshigoyal9018
    @sakshigoyal9018 3 роки тому

    sir my js code is not working i am not getting why?

  • @dominicvolante1616
    @dominicvolante1616 3 роки тому

    This is the easiest Modal I've ever seen

  • @Christfemme
    @Christfemme 3 роки тому +1

    This is great, and really helped me. However, I have 3 buttons that need to open 3 separate modals, and I although all three of them open (one at a time), I cannot get the last two to close.

  • @damolaadigun9574
    @damolaadigun9574 4 роки тому

    i wanted the modal to be on top of my content but it keeps scattering the arrangement

  • @antoniosalzano5253
    @antoniosalzano5253 4 роки тому +1

    i can't see the start of the css..

  • @priyankanispro
    @priyankanispro 3 роки тому +4

    You can Use "×" for the Cross Sign. Ex:
    ×
    The Result will be like This: ×

  • @ectoplasm1285
    @ectoplasm1285 6 років тому +1

    can you please share all of your css code ?

    • @uimonk
      @uimonk 5 років тому

      ua-cam.com/video/8A6mqAu4llg/v-deo.html
      this video has source code with explanation

  • @jojok.mikaka6955
    @jojok.mikaka6955 3 роки тому

    please ! show us the start of css code !

  • @aljoeanthonyberdin2845
    @aljoeanthonyberdin2845 4 роки тому

    Where did you get the .bg-active in CSS sir? im just a beginner I hope you notice my comment. Godbless! =)

    • @jamespawson6045
      @jamespawson6045 3 роки тому

      You add/create the class in CSS and then use JavaScript classList.add to add it to the html element when the button is clicked.

  • @stianhansen6738
    @stianhansen6738 5 років тому +3

    Thank you for your great tutorials! I wish you had the html and css code on github or similar for us to copy and paste. Would make it quite a bit easier to get into the js.

    • @amithshambu7181
      @amithshambu7181 3 роки тому

      Yes yes yes yes, someone please help!!!!!!!!

  • @BUDX
    @BUDX 4 роки тому

    How to close the modal by clicking outside of it

    • @vishalasthana8998
      @vishalasthana8998 4 роки тому

      window.addEventListener('click', (event) => {
      if(event.target === modal) {
      modal.classList.remove('bg-active');
      }
      });

  • @rohitkk1982
    @rohitkk1982 2 роки тому

    Can you share the code

  • @bukqueiroz
    @bukqueiroz 3 роки тому +1

    wtf what is the start css?????????????????????????????????????????????????????????????

  • @richestboy_uz
    @richestboy_uz 3 роки тому

    👍👍👍👍

  • @dilemma9865
    @dilemma9865 3 роки тому

    ❤❤

  • @ishaanpandey
    @ishaanpandey 3 роки тому +1

    did not work for me 😭😭😭😭

  • @STXplague
    @STXplague 4 роки тому

    Source code?

  • @sigmiami
    @sigmiami 5 років тому +7

    Didnt work

  • @HK-sw3vi
    @HK-sw3vi 3 роки тому

    les fucking gooooooooooooo!

  • @aligu7
    @aligu7 4 роки тому

    Could you send me a source code please :)