Create a Modal (Popup) with HTML/CSS and JavaScript

แชร์
ฝัง
  • เผยแพร่เมื่อ 16 เม.ย. 2020
  • 👉 Daily Coding Challenges: iCodeThis.com/?ref=ytb-modal
    In this tutorial, we're going to learn how to build a #Modal / #Popup using HTML, CSS, and a little bit of #JavaScript to toggle a class.
    ---
    Follow me on:
    📃 Website/Blog: florin-pop.com
    👉 Twitter: / florinpop1705
    👉 Linkedin: / florinpop17
    👉 Instagram: / florinpop17
    👉 Github: github.com/florinpop17
    👉 Twitch: twitch.com/florinpop17

ความคิดเห็น • 146

  • @devtest9282
    @devtest9282 3 ปีที่แล้ว +1

    short concise and crisp. Exactly what I wanted. Thank you

  • @KirkMitchelllelouprouge
    @KirkMitchelllelouprouge 2 ปีที่แล้ว +1

    This is one of the best modal tutorials I've tried and the first one to actually help me implement it into my site! Thank you!

  • @abdifatahmoh
    @abdifatahmoh 4 ปีที่แล้ว +7

    Well done, Florin. I actually like this kind of mini-js projects. It helps me to grasp how DOM JS works.

  • @KyleBondo
    @KyleBondo 3 ปีที่แล้ว

    Excellent tutorial! Short, sweet, and to the point -- and it WORKED!! Thank you!

  • @letrantuantai6889
    @letrantuantai6889 2 ปีที่แล้ว +3

    Your tutorial is awesome!!!! It is simple, straightforward and kind of easy to follow. Please keep up your good work.

  • @chiragjain4137
    @chiragjain4137 2 ปีที่แล้ว +1

    I was really struggling with creating a Modal of my own. I was tangled in min-height, max-height. Could not even center the Wrapper div. Great video. Position fixed made a perspective a little clearer. Thank You.❤

  • @SocialIntrovert29
    @SocialIntrovert29 3 หลายเดือนก่อน

    Taking a front end class in masters, you just saved my assignment. deserve a subscribe. :)

  • @kettenbach
    @kettenbach 4 ปีที่แล้ว +1

    I think I'm addicted to the sound effects at the beginning of your videos. So digital! 😀👍

  • @tenc6491
    @tenc6491 2 ปีที่แล้ว

    I am glad to have found your page coz I get to learn awesome stuffs with your easy-to-comprehend-tutorials.
    You're really good. Thanks for sharing such wonderful tutorials.

  • @victormarinviloria633
    @victormarinviloria633 4 ปีที่แล้ว

    Thanks, Florin! Loved your way of explaining!

  • @iUmerFarooq
    @iUmerFarooq 4 ปีที่แล้ว +2

    Wow, I love this waiting for more like this.
    I have learned something new like *pointer-event* how this works.
    Thank you And *must always use JS in your every Tutorial.*

  • @hemantnimble8442
    @hemantnimble8442 ปีที่แล้ว

    Thanks a lot!
    I was struggling with popup modal you gave me the basic idea to execute what i was planning , It helped me a lot

  • @kbhargavi4400
    @kbhargavi4400 2 ปีที่แล้ว

    superb explaination ! Simple n easy ! Learnt a lot in short time . Thank you florin .

  • @BlueMoises96
    @BlueMoises96 3 ปีที่แล้ว

    the best modal js video i have ever seen, thanks for share with us.

  • @maximepoitoux4541
    @maximepoitoux4541 3 ปีที่แล้ว +1

    Thanks again Florin, you are the best !

  • @cosy5112
    @cosy5112 2 ปีที่แล้ว

    Thank you, super easy to follow!

  • @nilamrakholiya5650
    @nilamrakholiya5650 3 ปีที่แล้ว

    Too useful thing explained in too less time . ..amazing👍 thank you sir

  • @zaka2
    @zaka2 4 ปีที่แล้ว +17

    wow, watched too many videos abuse youtube's 10min rule, it feels awesome to see something beautiful made in this time, thanks

    • @FlorinPop
      @FlorinPop  4 ปีที่แล้ว +1

      Glad you like it 😄

    • @jeremiascristian521
      @jeremiascristian521 3 ปีที่แล้ว

      You prolly dont give a shit but if you're bored like me atm then you can watch all the latest movies and series on InstaFlixxer. Been streaming with my brother for the last few days :)

    • @axtonkarson2634
      @axtonkarson2634 3 ปีที่แล้ว

      @Jeremias Cristian yup, have been using Instaflixxer for since december myself :D

    • @ashwathmittal99
      @ashwathmittal99 3 ปีที่แล้ว

      @@FlorinPop Can I get the code ?

  • @wetsand7379
    @wetsand7379 2 ปีที่แล้ว

    thank you for this tutorial! it was really easy to understand and follow.

  • @bipashamazumder1884
    @bipashamazumder1884 2 ปีที่แล้ว

    Wow learnt too many things in just 10 mins🙂 thank you sir

  • @blabberq
    @blabberq 2 ปีที่แล้ว

    That was what I need, thank you :)

  • @kojoarhin8634
    @kojoarhin8634 2 หลายเดือนก่อน

    Appreciate you
    Helped me solve an issue

  • @ricardodesirat2590
    @ricardodesirat2590 4 ปีที่แล้ว +7

    Hey Florin!
    Great video, as always. Love the way you quickly explain every step.
    One doubt.. could/or does it make sense to use classList.toggle instead of the .remove & .add?

    • @FlorinPop
      @FlorinPop  ปีที่แล้ว +1

      You are right!

  • @jafartouzeau2461
    @jafartouzeau2461 หลายเดือนก่อน

    Thank you so much that was very helpful !

    • @FlorinPop
      @FlorinPop  23 วันที่ผ่านมา

      Glad it was helpful!

  • @madu6451
    @madu6451 3 ปีที่แล้ว

    This tutorial was great!

  • @sanasamir7129
    @sanasamir7129 2 ปีที่แล้ว

    Love the video. Thank you.

  • @aldorsan
    @aldorsan 3 ปีที่แล้ว

    Excelent tutorial. Good work

  • @Kreytonchild
    @Kreytonchild 10 หลายเดือนก่อน

    awesome! thank you so much!

  • @KanekiSidibe
    @KanekiSidibe 10 หลายเดือนก่อน

    Well explained thanks!

  • @OyiboVFX
    @OyiboVFX 4 หลายเดือนก่อน

    Struggling with modals. But yours works fine. Thanks

    • @OyiboVFX
      @OyiboVFX 4 หลายเดือนก่อน

      Update… works fine as a stand alone HTML file. But does not work in Bootstrap Studio. The search continues

  • @lillianho6613
    @lillianho6613 ปีที่แล้ว

    Hi Florin, thank you for the tutorial! I'm pretty new to HTML/CSS/JS and wanted to implement an info button that would create a modal popup when clicked upon. For some reason, when I click the button, the background becomes darker but the modal doesn't show for some reason. I tried following along on a fresh project with nothing else on it, and I was able to make the modal appear when copying and pasting the code I wrote on the previous project. Do you have any idea why this might be occurring?

  • @sheraz_razzaq
    @sheraz_razzaq 2 ปีที่แล้ว

    Nice Florin Thank you for sharing.

  • @BahawalTV
    @BahawalTV 4 ปีที่แล้ว

    Well done Florin!

  • @nickapeed
    @nickapeed 3 ปีที่แล้ว +7

    I feel like this sounds silly but it would be a great help to have a copy of the code. When i set pointer-events to none i still can't click the button 7:12 . Also can't figure out why my 'click me please' button centered horizontally. Either way thank you for posting!

  • @dikshyantauprety4020
    @dikshyantauprety4020 ปีที่แล้ว

    Thank you so much..

  • @saikiduong4179
    @saikiduong4179 3 ปีที่แล้ว

    Thank you for this tutorial

  • @skysmeller
    @skysmeller ปีที่แล้ว

    Damn, man TY very much! U saved me ^^

  • @kugi7786
    @kugi7786 3 ปีที่แล้ว

    So smooth.

  • @ProgramWithErik
    @ProgramWithErik 4 ปีที่แล้ว

    I just made this in Vue! :) and Tailwind on my channel, what a coicidence :)

  • @lambdatraveller4316
    @lambdatraveller4316 4 ปีที่แล้ว

    Please make such short videos.. Many things to learn

  • @HarshitSharmaVlogss
    @HarshitSharmaVlogss 3 ปีที่แล้ว

    Great Video!!!!

  • @aymdatenth1796
    @aymdatenth1796 ปีที่แล้ว

    thank you it helped me

  • @remax110
    @remax110 4 ปีที่แล้ว +1

    Great tutorial. I like this mini project. Thank you.

  • @adao5308
    @adao5308 2 ปีที่แล้ว

    Thank you!

  • @ariankheradmand4947
    @ariankheradmand4947 2 ปีที่แล้ว

    Thank you so much

  • @s000sdas
    @s000sdas 2 ปีที่แล้ว

    Vreau sa devin programator ca tine Florin!

  • @jhonjairorengifovera9185
    @jhonjairorengifovera9185 3 ปีที่แล้ว

    nice men, but i have a question, how disable scroll when open the modal

  • @emmanuelphillip5856
    @emmanuelphillip5856 7 หลายเดือนก่อน

    Thank you. How do i get the modal to open automatically when the index of a site is accessed?

  • @jatinraj4974
    @jatinraj4974 4 ปีที่แล้ว +2

    After era of long live streaming here comes small video tutorial which we all love😍😍🤘🤘🤘

  • @raedsalah
    @raedsalah 4 ปีที่แล้ว +1

    that's a great video. +1 sub

  • @timonwill1
    @timonwill1 4 ปีที่แล้ว +1

    Nice!

  • @ravikethe8729
    @ravikethe8729 2 ปีที่แล้ว +2

    very nice, do you have source code listed somewhere? that will definitely help many of us to save some time too.

  • @icrmsoftware59
    @icrmsoftware59 ปีที่แล้ว

    Thank you

  • @willnovan6373
    @willnovan6373 ปีที่แล้ว

    for everyone that is asking why the button can't click nor open the modal, i wanna know if u guys r using or no. if yes then u have to place it in not in . it works for me.

    • @FlorinPop
      @FlorinPop  ปีที่แล้ว

      Or you can add the “defer” attribute on the script tag

  • @user-se6ct5zu2f
    @user-se6ct5zu2f 2 ปีที่แล้ว

    thank you!

  • @shanKirs10
    @shanKirs10 4 ปีที่แล้ว +1

    Thank you - A very good one.
    But how would we disable the scroll bar and any scrolling.

    • @FlorinPop
      @FlorinPop  4 ปีที่แล้ว +2

      You could set the body to be overflow hidden.

  • @AgniVibes
    @AgniVibes ปีที่แล้ว

    excelent tutorial bro, m ai scos din belea! XD
    o singura rugaminte as avea daca se poate sa ti egalezi levelul (dB) al muzicii cu cel al vocii pe final ptr ca diferenta de volum e uriasa.... am sarit din scaun! lol
    Merci inca o data! 👍👍👍

  • @alvarocampos1495
    @alvarocampos1495 ปีที่แล้ว

    Very nice

  • @xeztonic
    @xeztonic 2 ปีที่แล้ว

    LOVE YOU

  • @user-hx4uf3tc3i
    @user-hx4uf3tc3i 2 ปีที่แล้ว

    I like this 👍.

  • @augischadiegils.5109
    @augischadiegils.5109 2 ปีที่แล้ว

    thanks

  • @rayahmed2202
    @rayahmed2202 3 ปีที่แล้ว

    Thanks

  • @heraldocastillo8763
    @heraldocastillo8763 3 ปีที่แล้ว

    Thanks sr

  • @ehtishamliaqat9510
    @ehtishamliaqat9510 3 ปีที่แล้ว

    Amazing

  • @DevHasan
    @DevHasan ปีที่แล้ว

    awesome

  • @dexterdragons
    @dexterdragons 3 ปีที่แล้ว

    hey, how to refresh, scrollTop modal? e.x. boostrap modal - Scrolling long content, how to? help? tutorial?

  • @marrisaikrishna416
    @marrisaikrishna416 2 ปีที่แล้ว

    Awesome

  • @tejasparse9053
    @tejasparse9053 2 ปีที่แล้ว

    Why not make display none instead of switching opacities?

  • @bessa9181
    @bessa9181 2 ปีที่แล้ว

    What can I do if I want to allow the user to close the modal just clicking outside the modal box?

  • @proprogramming7203
    @proprogramming7203 3 ปีที่แล้ว

    is it gonna work when we put an image instead of button. please reply.😯

  • @arescatalin1407
    @arescatalin1407 3 ปีที่แล้ว

    The next Brad Traversy... mark my words!!

  • @aramartin2804
    @aramartin2804 2 ปีที่แล้ว

    Is it possible that when you click the close me button, it will lead you to next webpage?

  • @iliyalyan8937
    @iliyalyan8937 3 ปีที่แล้ว

    how to make one for each item in table?

  • @aswinm459
    @aswinm459 2 ปีที่แล้ว

    nice video

  • @blank_sfr
    @blank_sfr 2 ปีที่แล้ว

    Question! you defined the modal inside the container(overlay). now is there a way to close the modal by clicking the gray area?
    also thanks for the great content!!

    • @emanuellamba5828
      @emanuellamba5828 2 ปีที่แล้ว

      Yes, you can put a click eventlistener on the div with the gray area which will remove the 'show' class from the modal container

  • @MrsLalaina
    @MrsLalaina 2 ปีที่แล้ว

    Hello !
    Thanks, that's great !, now how to make it responsive? (sorry for my english, i'm French ^^)

  • @vikasjain8097
    @vikasjain8097 2 ปีที่แล้ว

    How to set automatic popup when page load

  • @Marian5Feb1971
    @Marian5Feb1971 4 ปีที่แล้ว

    Great tutorial on creating a Modal....I am trying to pass data(unordered list) from a html page to another html page or modal. Can data be passed into Modal and should I use local storage, any suggestions would be appreciated.

    • @FlorinPop
      @FlorinPop  4 ปีที่แล้ว

      You can use that, yes.

  • @Uzakoff_u
    @Uzakoff_u ปีที่แล้ว

    🔥🔥

  • @gamingvortx4630
    @gamingvortx4630 2 ปีที่แล้ว

    which ide u r using

  • @ourielperez1646
    @ourielperez1646 3 ปีที่แล้ว +1

    Hello Florin.
    Thanks for all your videos :)
    Just one question: how can we add emojis on Codepen like you did?
    Thank you in advance.
    Have a good week :)

  • @ekaterinaropleva2406
    @ekaterinaropleva2406 3 ปีที่แล้ว

    Hey Florin, awesome tutorial. Perfectly worked with me. However, could you please explain to me how can I make multiple modals to open when clicking multiple buttons. I mean the following: I have a card gallery, and every card has a "Read more" button, which shows different information. Thanks in advance and keep up the awesome work! Best wishes from Bulgaria 💙

    • @valentepablo
      @valentepablo 3 ปีที่แล้ว

      In that case, your modal would be like a component because you would use it a couple times. The best for that is working with Classes. It's a little bit more advanced but really saves you on the long run.

    • @johnme60
      @johnme60 2 ปีที่แล้ว +1

      @@valentepablo Comment is 1 year old I hop you guys doing well in life. but maybe someone reading it now, I'll suggest a trick from my limited knowledge.
      1. Assume modal has a heading h1 tag, and a body with tags ; give them unique IDs
      2. Every read more button invokes a function , this functions takes "text and headline" as input.
      3. you can read the text from a text file or just write in the js file.
      4. this function receive the text and headline , and use it to change the "innerText" property of modal .
      5 . now the h1 heading tag is changed with your given headline and tag with detailed paragraph.
      6. Every readmore button has a unique Id , according to that ID ,the function can change modal text every time with different text and headline.

  • @stefanpfadt4353
    @stefanpfadt4353 2 ปีที่แล้ว

    WOW! can i make the popup only appear when a specific user clicks on it, e.g. guest?

  • @deivi3697
    @deivi3697 2 ปีที่แล้ว

    How i do it with SessionStorage y localStorage?

  • @shubhammane2373
    @shubhammane2373 2 ปีที่แล้ว

    how to make nested modal

  • @arantube8211
    @arantube8211 ปีที่แล้ว

    What name of code editor used

  • @abdifatahmoh
    @abdifatahmoh 4 ปีที่แล้ว

    Can we set click me button's z-index:1; instead of setting modal-container to pointer-events: none; so the button can be on top of the modal-container ? Also set the modal-container display: none; , and from there in javascript style it to display: 'block'; when the button even listener is clicked.

    • @FlorinPop
      @FlorinPop  4 ปีที่แล้ว +1

      You won’t have the transition with display

  • @Badtricks
    @Badtricks 3 ปีที่แล้ว

    where can we get the code

  • @karthikgovindappa
    @karthikgovindappa 4 ปีที่แล้ว +4

    Can we use display:none instead of opacity ?

    • @FlorinPop
      @FlorinPop  4 ปีที่แล้ว +3

      You wouldn’t have the transition

    • @sidheshwartiwari9834
      @sidheshwartiwari9834 3 ปีที่แล้ว +2

      @@FlorinPop got my answer..
      Thanks

  • @arunagirim3455
    @arunagirim3455 2 ปีที่แล้ว

    could you tell the directory of the source code in github

  • @apurvashah9207
    @apurvashah9207 3 ปีที่แล้ว

    Best

  • @AjayKumar-ft4ge
    @AjayKumar-ft4ge 3 ปีที่แล้ว

    you should have shared your code for practising

  • @GuilhermeSouza-zh6go
    @GuilhermeSouza-zh6go 2 ปีที่แล้ว

    I'm having problems, when I put fixed position it fixes the whole page and when it opens, it doesn't close

  • @Vipeeri
    @Vipeeri 2 ปีที่แล้ว

    What if I need 1000x modals? Then I'd have quite many unnecessary layers of js running on a website. Isn't there any way of creating the modals dynamically?

  • @NottanALias
    @NottanALias 2 ปีที่แล้ว +2

    total beginner here. when i try to do this, I always get: 'open is null'
    no idea why, I am working in cs code, referencing the .js from the HTML header using
    any tips?

    • @blank_sfr
      @blank_sfr 2 ปีที่แล้ว

      the standard form is tu put the script tag at the bottom of body tag.
      make sure you passed the "open" id to the html BUTTON tag and your DOM selector is not having a problem.
      its all about debugging bro :D

  • @gurametempe3011
    @gurametempe3011 2 ปีที่แล้ว

    Pointer-events not working help me please sir

  • @Andrei-gd1wx
    @Andrei-gd1wx 2 ปีที่แล้ว

    I love you Dl. Florin

  • @nazlue
    @nazlue 2 ปีที่แล้ว

    I prefer a no-code popup builder like Popupsmart as I have no code knowledge. Veery easy

    • @marygracetecson7148
      @marygracetecson7148 7 หลายเดือนก่อน

      Please share your code to save us time keying it. and just experiment with it. Thanks

  • @aditya_gupta
    @aditya_gupta 4 ปีที่แล้ว

    Why not use visibility: hidden ?

    • @FlorinPop
      @FlorinPop  4 ปีที่แล้ว

      Because you cannot see a transition using visibility.

  • @olanitoritobi5107
    @olanitoritobi5107 2 ปีที่แล้ว

    mine doesn't work please help! the button does nothing!